Skip to content

$scopedSlots for item component #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ More usages or getting start you can refer to these clearly [examples](https://g
<td>{}</td>
<td>For using using footer slot, footer slot wrapper element inline style.</td>
</tr>
<tr>
<td><code>scoped-slots</code></td>
<td>Object</td>
<td>{}</td>
<td>$scopedSlots for item component</td>
</tr>
</table>
</details>

Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const VirtualList = Vue.component('virtual-list', {
getRenderSlots (h) {
const slots = []
const { start, end } = this.range
const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent } = this
const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent, scopedSlots } = this
for (let index = start; index <= end; index++) {
const dataSource = dataSources[index]
if (dataSource) {
Expand All @@ -277,7 +277,8 @@ const VirtualList = Vue.component('virtual-list', {
uniqueKey: dataSource[dataKey],
source: dataSource,
extraProps: extraProps,
component: dataComponent
component: dataComponent,
scopedSlots: scopedSlots
},
style: itemStyle,
class: `${itemClass}${this.itemClassAdd ? ' ' + this.itemClassAdd(index) : ''}`
Expand Down
5 changes: 3 additions & 2 deletions src/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Item = Vue.component('virtual-list-item', {
props: ItemProps,

render (h) {
const { tag, component, extraProps = {}, index } = this
const { tag, component, extraProps = {}, index, scopedSlots = {} } = this
extraProps.source = this.source
extraProps.index = index

Expand All @@ -60,7 +60,8 @@ export const Item = Vue.component('virtual-list-item', {
role: 'item'
}
}, [h(component, {
props: extraProps
props: extraProps,
scopedSlots: scopedSlots
})])
}
})
Expand Down
6 changes: 6 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export const VirtualProps = {
},
footerStyle: {
type: Object
},
scopedSlots: {
type: Object
}
}

Expand Down Expand Up @@ -129,6 +132,9 @@ export const ItemProps = {
},
extraProps: {
type: Object
},
scopedSlots: {
type: Object
}
}

Expand Down