@@ -31,16 +31,12 @@ npm istall vue-virtual-scroll-grid
31
31
<Grid :length="1000" :pageSize="2" :pageProvider="pageProvider" class="grid">
32
32
<!-- When the item is not loaded, a placeholder is rendered -->
33
33
<template v-slot:placeholder="{ index, style }">
34
- <div class="item" :style="style">
35
- Placeholder {{ index }}
36
- </div>
34
+ <div class="item" :style="style">Placeholder {{ index }}</div>
37
35
</template>
38
36
39
37
<!-- Render a loaded item -->
40
38
<template v-slot:default="{ item, style, index }">
41
- <div class="item" :style="style">
42
- {{ item }} {{ index }}
43
- </div>
39
+ <div class="item" :style="style">{{ item }} {{ index }}</div>
44
40
</template>
45
41
</Grid>
46
42
</template>
@@ -49,9 +45,9 @@ npm istall vue-virtual-scroll-grid
49
45
import Grid from "vue-virtual-scroll-grid";
50
46
51
47
export default {
52
- name : "App",
53
- components: {Grid},
54
- setup : () => ({
48
+ name: "App",
49
+ components: { Grid },
50
+ setup: () => ({
55
51
// Return items for the given page after a 0-3 second randomly
56
52
pageProvider: (pageNumber, pageSize) =>
57
53
new Promise((resolve) =>
@@ -140,28 +136,39 @@ interface Props {
140
136
// must be an integer and greater than or equal to 0.
141
137
length: number ;
142
138
// The callback that returns a page of items as a promise.
143
- pageProvider: (pageNumber : number , pageSize : number ) => Promise <unknown []>
139
+ pageProvider: (pageNumber : number , pageSize : number ) => Promise <unknown []>;
144
140
// The number of items in a page from the item provider (e.g. a backend API),
145
141
// must be an integer and greater than or equal to 0.
146
142
pageSize: number ;
147
143
}
148
144
```
149
145
150
- ## Available Scoped Slots
146
+ ## Available Slots
151
147
152
- There are 2 scoped slots: ` default ` and ` placeholder ` . Both of them have the
153
- following slot props:
148
+ There are 3 scoped slots: ` default ` , ` placeholder ` and ` probe ` .
154
149
150
+ Props of the ` default ` slot:
151
+
152
+ - ` item ` : the loaded item that is used for rendering your item
153
+ element/component.
155
154
- ` index ` : the index of current item within the list.
156
155
- ` style ` : the style object provided by the library that need to be set on the
157
156
item element/component.
158
157
159
- The ` default ` slot has an extra prop ` item ` , which is the loaded item that is
160
- used for rendering your item element/component.
158
+ Props of the ` placeholder ` slot:
159
+
160
+ - ` index ` : the index of current item within the list.
161
+ - ` style ` : the style object provided by the library that need to be set on the
162
+ item element/component.
161
163
162
164
The ` placeholder ` slot is optional. If missing, the space of unloaded items will
163
165
be blank until they are loaded.
164
166
167
+ The ` probe ` slot has no prop. It is used to measure the visual size of grid
168
+ item. If not provided, you must set a fixed height to ` grid-template-rows ` on
169
+ your CSS grid, or a fixed ` height ` on your item element/component, e.g. ` 200px ` .
170
+ Otherwise, the view won't be rendered properly.
171
+
165
172
## Development
166
173
167
174
- Setup ` npm install `
0 commit comments