File tree 1 file changed +38
-5
lines changed
1 file changed +38
-5
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" dynamic-scroller-demo" >
3
+ <div class =" toolbar" >
4
+ <input
5
+ v-model =" search"
6
+ placeholder =" Filter..."
7
+ >
8
+ </div >
9
+
3
10
<DynamicScroller
4
- :items =" items "
11
+ :items =" filteredItems "
5
12
:min-item-height =" 54"
6
13
class =" scroller"
7
14
>
8
- <div slot =" before-container" class =" notice" >
15
+ <div
16
+ slot =" before-container"
17
+ class =" notice"
18
+ >
9
19
The message heights are unknown.
10
20
</div >
11
21
24
34
>
25
35
<div class =" avatar" >
26
36
<img
27
- :src =" item.avatar"
28
37
:key =" item.avatar"
38
+ :src =" item.avatar"
29
39
alt =" avatar"
30
40
class =" image"
31
41
>
32
42
</div >
33
43
<div class =" text" >
34
- {{ index }}
35
44
{{ item.message }}
36
45
</div >
46
+ <div class =" index" >
47
+ <span >{{ item.id }} (id)</span >
48
+ <span >{{ index }} (index)</span >
49
+ </div >
37
50
</DynamicScrollerItem >
38
51
</template >
39
52
</DynamicScroller >
@@ -55,9 +68,19 @@ export default {
55
68
data () {
56
69
return {
57
70
items,
71
+ search: ' ' ,
58
72
}
59
73
},
60
74
75
+ computed: {
76
+ filteredItems () {
77
+ const { search , items } = this
78
+ if (! search) return items
79
+ const lowerCaseSearch = search .toLowerCase ()
80
+ return items .filter (i => i .message .toLowerCase ().includes (lowerCaseSearch))
81
+ },
82
+ },
83
+
61
84
methods: {
62
85
changeMessage (message ) {
63
86
Object .assign (message, generateMessage ())
@@ -87,7 +110,6 @@ export default {
87
110
min-height : 32px ;
88
111
padding : 12px ;
89
112
box-sizing : border-box ;
90
- max-width : 400px ;
91
113
}
92
114
93
115
.avatar {
@@ -104,7 +126,18 @@ export default {
104
126
border-radius : 50% ;
105
127
}
106
128
129
+ .index ,
107
130
.text {
108
131
flex : 1 ;
109
132
}
133
+
134
+ .text {
135
+ max-width : 400px ;
136
+ }
137
+
138
+ .index span {
139
+ display : inline-block ;
140
+ width : 160px ;
141
+ text-align : right ;
142
+ }
110
143
</style >
You can’t perform that action at this time.
0 commit comments