Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ const VirtualList = Vue.component('virtual-list', {
const slots = []
const { start, end } = this.range
const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent, itemScopedSlots } = this
const slotComponent = this.$scopedSlots && this.$scopedSlots.item
for (let index = start; index <= end; index++) {
const dataSource = dataSources[index]
if (dataSource) {
Expand All @@ -286,6 +287,7 @@ const VirtualList = Vue.component('virtual-list', {
source: dataSource,
extraProps: extraProps,
component: dataComponent,
slotComponent: slotComponent,
scopedSlots: itemScopedSlots
},
style: itemStyle,
Expand Down
4 changes: 2 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, source, scopedSlots = {}, uniqueKey } = this;
const { tag, component, extraProps = {}, index, source, scopedSlots = {}, uniqueKey, slotComponent } = this;
const props = {
...extraProps,
source,
Expand All @@ -63,7 +63,7 @@ export const Item = Vue.component('virtual-list-item', {
attrs: {
role: 'listitem'
}
}, [h(component, {
}, [slotComponent ? h('div', slotComponent({ item: source, index: index, scope: props })) : h(component, {
props,
scopedSlots: scopedSlots
})])
Expand Down
3 changes: 3 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export const ItemProps = {
component: {
type: [Object, Function]
},
slotComponent: {
type: Function
},
uniqueKey: {
type: [String, Number]
},
Expand Down