File tree Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,10 @@ export default defineConfig({
164164 text : 'List 滚动列表' ,
165165 link : '/components/list' ,
166166 } ,
167+ {
168+ text : 'VirtualList 虚拟列表' ,
169+ link : '/components/virtuallist' ,
170+ } ,
167171 {
168172 text : 'Tabs 标签页' ,
169173 link : '/components/tabs' ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import '../../../style/tag';
4040import '../../../style/pagination' ;
4141import '../../../style/tanstack-table' ;
4242import '../../../style/md-input' ;
43+ import '../../../style/virtual-list' ;
4344
4445export default {
4546 extends : DefaultTheme ,
Original file line number Diff line number Diff line change 1+ # VirtualList 虚拟列表
2+
3+ 当我们遇到数据量很大的情况时,传统的渲染方式会导致浏览器负载过大,页面渲染速度慢,滚动卡顿等一系列问题。
4+
5+ 对于这种列表数据,我们可以采用虚拟滚动来进行性能优化。
6+
7+ ## 演示
8+
9+ <script setup >
10+ import { VirtualList } from " ../../src"
11+ </script >
12+
13+ ### 基础用法
14+
15+ 对于固定高度, 一次性渲染 ` 10w ` 条数据。
16+
17+ <ClientOnly >
18+ <CodePreview >
19+ <textarea lang =" vue " >
20+ <script setup>
21+ </script>
22+ <template>
23+ </template>
24+ </textarea >
25+ <template #preview>
26+ <div class =" virtual-list-demo-container " >
27+ <VirtualList ></VirtualList >
28+ </div >
29+ </template >
30+ </CodePreview >
31+ </ClientOnly >
32+
33+ ## API
34+
35+ ### VirtualList Props
36+
37+ <!-- prettier-ignore -->
38+ | 参数 | 说明 | 类型 | 默认值 |
39+ | --- | --- | --- | --- |
40+ | x | x | x | x |
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" nt-virtual-list" >
3+ <!-- 占位元素, 用于撑开滚动条,达到滚动效果 -->
4+ <div class =" nt-virtual-placeholder" ></div >
5+ <!-- 内容元素, 用于显示列表项 -->
6+ <div class =" nt-virtual-content" >
7+ <!-- 列表项 -->
8+ <div class =" nt-virtual-item" ></div >
9+ </div >
10+ </div >
11+ </template >
12+ <script setup lang="ts"></script >
Original file line number Diff line number Diff line change @@ -71,3 +71,4 @@ export { default as Loading } from './directives/loading';
7171export { default as PageHeader } from './components/PageHeader.vue' ;
7272export { default as Tag } from './components/Tag.vue' ;
7373export { default as Pagination } from './components/Pagination.vue' ;
74+ export { default as VirtualList } from "./components/VirtualList.vue" ;
Original file line number Diff line number Diff line change 237237select {
238238 appearance : auto;
239239}
240+
241+ .virtual-list-demo-container {
242+ height : 240px ;
243+ }
Original file line number Diff line number Diff line change 1+ .nt-virtual-list {
2+ height : 100% ;
3+ overflow-y : auto;
4+ -webkit-overflow-scrolling : touch;
5+ }
6+
7+ .nt-virtual-item {
8+ overflow : hidden;
9+ }
Original file line number Diff line number Diff line change 1+ import "./index.css" ;
You can’t perform that action at this time.
0 commit comments