list-view.uvue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <cl-page>
  3. <view class="page">
  4. <view class="p-3 pb-0">
  5. <demo-item>
  6. <cl-text
  7. >采用虚拟列表技术实现高性能渲染,支持海量数据无限滚动,当前演示数据规模:{{
  8. data.length
  9. }}条</cl-text
  10. >
  11. </demo-item>
  12. </view>
  13. <view class="list">
  14. <cl-list-view
  15. :data="data"
  16. :pt="{
  17. indexBar: {
  18. className: '!fixed'
  19. }
  20. }"
  21. >
  22. </cl-list-view>
  23. </view>
  24. </view>
  25. </cl-page>
  26. </template>
  27. <script lang="ts" setup>
  28. import { request } from "@/cool";
  29. import DemoItem from "../components/item.uvue";
  30. import { useListView, type ClListViewItem } from "@/uni_modules/cool-ui";
  31. import { ref } from "vue";
  32. const data = ref<ClListViewItem[]>([]);
  33. onReady(() => {
  34. request<UTSJSONObject[]>({
  35. url: "https://unix.cool-js.com/data/pca_flat.json"
  36. })
  37. .then((res) => {
  38. data.value = useListView(res);
  39. })
  40. .catch((err) => {
  41. console.error(err);
  42. });
  43. });
  44. </script>
  45. <style lang="scss" scoped>
  46. .page {
  47. height: 100%;
  48. .list {
  49. flex: 1;
  50. }
  51. }
  52. </style>