Skip to content

Commit 3b5e7e4

Browse files
gr8dentangbc
authored andcommitted
for item component
1 parent 0ebea64 commit 3b5e7e4

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ More usages or getting start you can refer to these clearly [examples](https://g
317317
<td>{}</td>
318318
<td>For using using footer slot, footer slot wrapper element inline style.</td>
319319
</tr>
320+
<tr>
321+
<td><code>scoped-slots</code></td>
322+
<td>Object</td>
323+
<td>{}</td>
324+
<td>$scopedSlots for item component</td>
325+
</tr>
320326
</table>
321327
</details>
322328

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ const VirtualList = Vue.component('virtual-list', {
263263
getRenderSlots (h) {
264264
const slots = []
265265
const { start, end } = this.range
266-
const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent } = this
266+
const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent, scopedSlots } = this
267267
for (let index = start; index <= end; index++) {
268268
const dataSource = dataSources[index]
269269
if (dataSource) {
@@ -277,7 +277,8 @@ const VirtualList = Vue.component('virtual-list', {
277277
uniqueKey: dataSource[dataKey],
278278
source: dataSource,
279279
extraProps: extraProps,
280-
component: dataComponent
280+
component: dataComponent,
281+
scopedSlots: scopedSlots
281282
},
282283
style: itemStyle,
283284
class: `${itemClass}${this.itemClassAdd ? ' ' + this.itemClassAdd(index) : ''}`

src/item.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const Item = Vue.component('virtual-list-item', {
5151
props: ItemProps,
5252

5353
render (h) {
54-
const { tag, component, extraProps = {}, index } = this
54+
const { tag, component, extraProps = {}, index, scopedSlots = {} } = this
5555
extraProps.source = this.source
5656
extraProps.index = index
5757

@@ -60,7 +60,8 @@ export const Item = Vue.component('virtual-list-item', {
6060
role: 'item'
6161
}
6262
}, [h(component, {
63-
props: extraProps
63+
props: extraProps,
64+
scopedSlots
6465
})])
6566
}
6667
})

src/props.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ export const VirtualProps = {
102102
},
103103
footerStyle: {
104104
type: Object
105+
},
106+
scopedSlots: {
107+
type: Object,
105108
}
106109
}
107110

@@ -129,6 +132,9 @@ export const ItemProps = {
129132
},
130133
extraProps: {
131134
type: Object
135+
},
136+
scopedSlots: {
137+
type: Object,
132138
}
133139
}
134140

0 commit comments

Comments
 (0)