Skip to content

Commit

Permalink
Warning when data-key error
Browse files Browse the repository at this point in the history
  • Loading branch information
tangbc committed Apr 22, 2020
1 parent 5608548 commit c0f6423
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,24 @@ const VirtualList = Vue.component('virtual-list', {
for (let index = start; index <= end; index++) {
const dataSource = this.dataSources[index]
if (dataSource) {
slots.push(h(Item, {
class: this.itemClass,
props: {
tag: this.itemTag,
event: EVENT_TYPE.ITEM,
horizontal: this.isHorizontal,
uniqueKey: dataSource[this.dataKey],
source: dataSource,
extraProps: this.extraProps,
component: this.dataComponent
}
}))
if (dataSource[this.dataKey]) {
slots.push(h(Item, {
class: this.itemClass,
props: {
tag: this.itemTag,
event: EVENT_TYPE.ITEM,
horizontal: this.isHorizontal,
uniqueKey: dataSource[this.dataKey],
source: dataSource,
extraProps: this.extraProps,
component: this.dataComponent
}
}))
} else {
console.warn(`Cannot get the data-key '${this.dataKey}' from data-sources.`)
}
} else {
console.warn(`Cannot get the index ${index} from data-sources.`)
console.warn(`Cannot get the index '${index}' from data-sources.`)
}
}
return slots
Expand Down

0 comments on commit c0f6423

Please sign in to comment.