Files
WAI_Project_UNIX/pages/demo/data/list-view.uvue

69 lines
1.2 KiB
Plaintext
Raw Normal View History

2025-07-21 16:47:04 +08:00
<template>
<cl-page>
<view class="page">
<view class="p-3 pb-0">
<demo-item>
<cl-text
>采用虚拟列表技术实现高性能渲染,支持海量数据无限滚动,当前演示数据规模:{{
data.length
}}条</cl-text
>
</demo-item>
</view>
<view class="list">
<cl-list-view
:data="data"
:pt="{
indexBar: {
className: '!fixed'
2025-08-11 23:48:02 +08:00
},
itemHover: {
className: 'bg-gray-200'
2025-07-21 16:47:04 +08:00
}
}"
>
</cl-list-view>
</view>
</view>
</cl-page>
</template>
<script lang="ts" setup>
import { request } from "@/cool";
import DemoItem from "../components/item.uvue";
2025-08-11 23:48:02 +08:00
import { useListView, useUi, type ClListViewItem } from "@/uni_modules/cool-ui";
2025-07-21 16:47:04 +08:00
import { ref } from "vue";
2025-08-11 23:48:02 +08:00
const ui = useUi();
2025-07-21 16:47:04 +08:00
const data = ref<ClListViewItem[]>([]);
onReady(() => {
2025-08-11 23:48:02 +08:00
ui.showLoading();
request({
2025-08-03 17:05:03 +08:00
url: "https://unix.cool-js.com/data/pca_flat.json"
2025-07-21 16:47:04 +08:00
})
.then((res) => {
data.value = useListView(res as UTSJSONObject[]);
2025-07-21 16:47:04 +08:00
})
.catch((err) => {
console.error(err);
2025-08-11 23:48:02 +08:00
})
.finally(() => {
ui.hideLoading();
2025-07-21 16:47:04 +08:00
});
});
</script>
<style lang="scss" scoped>
.page {
height: 100%;
.list {
flex: 1;
}
}
</style>