You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-21Lines changed: 17 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@
25
25
*[Props type](#props-type)
26
26
*[Public methods](#public-methods)
27
27
*[Special scenes](#special-scenes)
28
-
*[About variable height](#about-variable-height)
28
+
*[About variable mode](#about-variable-mode)
29
29
*[About item mode](#about-item-mode)
30
30
*[Contributions](#contributions)
31
31
*[Changelogs](#changelogs)
@@ -142,28 +142,28 @@ new Vue({
142
142
| totop | Function | * | Called when virtual-list is scrolled to top, no param. |
143
143
| tobottom | Function | * | Called when virtual-list is scrolled to bottom, no param. |
144
144
| onscroll | Function | * | Called when virtual-list is scrolling, with param: [`(event, data)`](https://github.com/tangbc/vue-virtual-scroll-list/releases/tag/v1.1.7). |
145
-
| variable | Function or Boolean | * | For using virtual-list with`variable height mode`. If assign `Function`, this prop is a variable height getter function which is called with param: `(index)` when each item is ready to be calculated. If assign `Boolean`, virtual-list will get each item variable height by it's inline style height automatic. |
146
-
| item | Component | * | For using virtual-list with`itemmode` see [details](#about-item-mode) below. |
147
-
| itemdata | Array | * | For using virtual-list with`itemmode`see [details](#about-item-mode) below |
148
-
| itemprop | Function | * | For using virtual-list with`itemmode` see [details](#about-item-mode) below. |
145
+
| variable | Function or Boolean | * | For using virtual-list in`variable-mode`. If assign `Function`, this prop is a variable height getter function which is called with param: `(index)` when each item is ready to be calculated. If assign `Boolean`, virtual-list will get each item variable height by it's inline style height automatic. |
146
+
| item | Component | * | For using virtual-list in`item-mode`. List item vue component, see [details](#about-item-mode) below. |
147
+
| itemdata | Array | * | For using virtual-list in`item-mode`. Prop data list or item slots assign to each item, see [details](#about-item-mode) below.|
148
+
| itemprop | Function | * | For using virtual-list in`item-mode`. Function call when each item is going to be rendered, see [details](#about-item-mode) below. |
149
149
150
150
151
151
## Public methods
152
152
153
-
Here are some usefull public methods if you can call via [`ref`](https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements):
153
+
Here are some usefull public methods you can call via [`ref`](https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements):
154
154
155
155
*`forceRender()`: force render virtual-list if you need or make it refresh.
156
156
157
-
*`updateVariable(index)`: update variable by index in variable height mode.
157
+
*`updateVariable(index)`: update item height by index in variable height mode.
158
158
159
159
160
160
## Special scenes
161
161
162
-
### About variable height
162
+
### About variable mode
163
163
164
-
In variable height mode, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cache, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
164
+
In `variable-mode`, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cache, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
165
165
166
-
If you are using `variable`assign by `Boolean`, **do not** set inline style height inside `<item/>` component, you **must** set inline style height on `<item/>` component outside directly, such as:
166
+
If you assign `variable`as `true`, **do not** set inline style height inside `<item/>` component, you **must** set inline style height on `<item/>` component outside directly, such as:
167
167
```vue
168
168
<template>
169
169
<div>
@@ -176,15 +176,9 @@ If you are using `variable` assign by `Boolean`, **do not** set inline style hei
176
176
177
177
### About item mode
178
178
179
-
Use itemmode can save a considerable amount of memory, stats can see[#87](https://github.com/tangbc/vue-virtual-scroll-list/pull/87).
179
+
Use `item-mode` can save a considerable amount of memory, stats data check here:[#87](https://github.com/tangbc/vue-virtual-scroll-list/pull/87).
180
180
181
-
In this mode prop `item`, `itemdata` and `itemprop` is both required, you don't need put `<item/>` inside `virtual-list` just assign it as prop `item`:
182
-
183
-
*`item`: The list vue item component.
184
-
185
-
*`itemdata`: The prop data list assign to each item.
186
-
187
-
*`itemprop`: Call when each item is going to be rendered.
181
+
In this mode, prop `item``itemdata``itemprop` are both required, and you don't have to put `<item/>` with a v-for frag inside `virtual-list`, just assign it as prop `item`:
188
182
189
183
```vue
190
184
<template>
@@ -209,11 +203,13 @@ In this mode prop `item`, `itemdata` and `itemprop` is both required, you don't
209
203
}
210
204
},
211
205
methods: {
206
+
// index: item index
207
+
// data: item data get from itemdata array
212
208
itemprop (index, data) {
209
+
const id = { data }
210
+
const itemProps = getItemProp(id)
213
211
return {
214
-
props: {
215
-
data
216
-
}
212
+
props: itemProps // <item/> will receive prop with itemProps
0 commit comments