File tree Expand file tree Collapse file tree 3 files changed +135
-0
lines changed Expand file tree Collapse file tree 3 files changed +135
-0
lines changed Original file line number Diff line number Diff line change 9
9
<router-link :to =" { name: 'recycle' }" >Recycle scroller demo</router-link >
10
10
<router-link :to =" { name: 'dynamic' }" >Dynamic scroller demo</router-link >
11
11
<router-link :to =" { name: 'test-chat' }" >Chat demo</router-link >
12
+ <router-link :to =" { name: 'simple-list' }" >Simple array</router-link >
12
13
</nav >
13
14
<router-view class =" page" />
14
15
</div >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" dynamic-scroller-demo" >
3
+ <div class =" toolbar" >
4
+ <input
5
+ v-model =" search"
6
+ placeholder =" Filter..."
7
+ >
8
+
9
+ <label >
10
+ <input type =" checkbox" v-model =" dynamic" >
11
+ Dynamic scroller
12
+ </label >
13
+ </div >
14
+
15
+ <DynamicScroller
16
+ v-if =" dynamic"
17
+ :items =" filteredItems"
18
+ :min-item-height =" 54"
19
+ class =" scroller"
20
+ >
21
+ <div
22
+ slot =" before-container"
23
+ class =" notice"
24
+ >
25
+ Array of simple strings (no objects).
26
+ </div >
27
+
28
+ <template slot-scope="{ item, index, active }">
29
+ <DynamicScrollerItem
30
+ :item =" item"
31
+ :index =" index"
32
+ :active =" active"
33
+ :data-index =" index"
34
+ :data-active =" active"
35
+ class =" message"
36
+ >
37
+ <div class =" text" >
38
+ {{ item }}
39
+ </div >
40
+ <div class =" index" >
41
+ <span >{{ index }} (index)</span >
42
+ </div >
43
+ </DynamicScrollerItem >
44
+ </template >
45
+ </DynamicScroller >
46
+
47
+ <RecycleScroller
48
+ v-else
49
+ :items =" filteredItems.map((o, i) => `${i}: ${o.substr(0, 42)}...`)"
50
+ :item-height =" 54"
51
+ class =" scroller"
52
+ >
53
+ <template slot-scope="{ item, index }">
54
+ <div class =" message" >
55
+ <div class =" text" >
56
+ {{ item }}
57
+ </div >
58
+ <div class =" index" >
59
+ <span >{{ index }} (index)</span >
60
+ </div >
61
+ </div >
62
+ </template >
63
+ </RecycleScroller >
64
+ </div >
65
+ </template >
66
+
67
+ <script >
68
+ import { generateMessage } from ' ../data'
69
+
70
+ const items = []
71
+ for (let i = 0 ; i < 10000 ; i++ ) {
72
+ items .push (generateMessage ().message )
73
+ }
74
+
75
+ export default {
76
+ data () {
77
+ return {
78
+ items,
79
+ search: ' ' ,
80
+ dynamic: true ,
81
+ }
82
+ },
83
+
84
+ computed: {
85
+ filteredItems () {
86
+ const { search , items } = this
87
+ if (! search) return items
88
+ const lowerCaseSearch = search .toLowerCase ()
89
+ return items .filter (i => i .toLowerCase ().includes (lowerCaseSearch))
90
+ },
91
+ },
92
+ }
93
+ </script >
94
+
95
+ <style scoped>
96
+ .dynamic-scroller-demo ,
97
+ .scroller {
98
+ height : 100% ;
99
+ }
100
+
101
+ .dynamic-scroller-demo {
102
+ overflow : hidden ;
103
+ }
104
+
105
+ .notice {
106
+ padding : 24px ;
107
+ font-size : 20px ;
108
+ color : #999 ;
109
+ }
110
+
111
+ .message {
112
+ display : flex ;
113
+ min-height : 32px ;
114
+ padding : 12px ;
115
+ box-sizing : border-box ;
116
+ }
117
+
118
+ .index ,
119
+ .text {
120
+ flex : 1 ;
121
+ }
122
+
123
+ .text {
124
+ max-width : 400px ;
125
+ }
126
+
127
+ .index span {
128
+ display : inline-block ;
129
+ width : 160px ;
130
+ text-align : right ;
131
+ }
132
+ </style >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Home from './components/Home.vue'
5
5
import Recycle from './components/RecycleScrollerDemo.vue'
6
6
import Dynamic from './components/DynamicScrollerDemo.vue'
7
7
import TestChat from './components/TestChat.vue'
8
+ import SimpleList from './components/SimpleList.vue'
8
9
9
10
Vue . use ( VueRouter )
10
11
@@ -14,5 +15,6 @@ export default new VueRouter({
14
15
{ path : '/recycle' , name : 'recycle' , component : Recycle } ,
15
16
{ path : '/dynamic' , name : 'dynamic' , component : Dynamic } ,
16
17
{ path : '/test-chat' , name : 'test-chat' , component : TestChat } ,
18
+ { path : '/simple-list' , name : 'simple-list' , component : SimpleList } ,
17
19
] ,
18
20
} )
You can’t perform that action at this time.
0 commit comments