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
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@
5
5
6
6
Smooth scroll with any amount of data ([demo](https://akryum.github.io/vue-virtual-scroller/)).
7
7
8
+
# Installation
9
+
8
10
```
9
11
npm install --save vue-virtual-scroller
10
12
```
@@ -25,10 +27,30 @@ import VirtualScroller from 'vue-virtual-scroller'
25
27
Vue.use(VirtualScroller)
26
28
```
27
29
30
+
# Usage
31
+
32
+
The virtual scroller has three required props:
33
+
34
+
-`items` is the list of items you want to display in the scroller. There can be several types of item.
35
+
-`renderers` is a map of component definitions objects or names for each item type.
36
+
-`itemHeight` is the display height of the items in pixels used to calculate the scroll height and position.
37
+
38
+
There are additional props you can use:
39
+
40
+
-`typeField` to customize which field is used on the items to get their type and use the corresponding definition in the `renderers` map. The default is `'type'`.
41
+
-`keyField` to customize which field is used on the items to set their `key` special attribute (see [the documation](https://vuejs.org/v2/api/#key)). The default is `'id'`.
42
+
43
+
The `renderers` map is an object containing a component definition for each possible value of the item type. **The component definition must have an `item` prop, that will get the item object to render in the scroller.**
44
+
45
+
Also, you need to set the size of the virtual-scroller element and the items elements (for example, with CSS).
46
+
47
+
# Example
48
+
28
49
```html
29
50
<template>
30
51
<divclass="demo">
31
52
<virtual-scroller
53
+
class="scroller"
32
54
:items="items"
33
55
:renderers="renderers"
34
56
item-height="22"
@@ -61,9 +83,17 @@ export default {
61
83
}),
62
84
}
63
85
</script>
64
-
```
65
86
66
-
Finally, set the size of the virtual-scroller element (for example, with CSS).
0 commit comments