Skip to content

Commit c63129f

Browse files
author
Nicolas Ngomai
authored
feat: throw error when key field does not exist in item (#265)
1 parent 3d24dc3 commit c63129f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/DynamicScrollerItem.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export default {
5050
5151
computed: {
5252
id () {
53-
return this.vscrollData.simpleArray ? this.index : this.item[this.vscrollData.keyField]
53+
if (this.vscrollData.simpleArray) return this.index;
54+
if (this.item.hasOwnProperty(this.vscrollData.keyField)) return this.item[this.vscrollData.keyField];
55+
throw new Error(`keyField '${this.vscrollData.keyField}' not found in your item. You should set a valid keyField prop on your Scroller`);
5456
},
5557
5658
size () {

0 commit comments

Comments
 (0)