一般是由于没有考虑item为空的情况,只需要加一个if来判断item是否为空即可。
例如下面的代码运行时会报错:TypeError: item is undefined,
handleSelectionChange(selection) {
this.userIds = selection.map((item) => { return item.id })
},
加上if判断item是否为空后,不在报错
handleSelectionChange(selection) {
this.userIds = selection.map((item) => {
if (item) { return item.id }
})
},