项目场景:
使用Element中的el-table生成表格时,控制台报错:“Error: row is required when get row identity”
问题描述
错误信息如下:

原因分析:
- 未添加row-key属性
- tableList类型不为[]
- 当调用getRowIdentity函数,但是参数为空的时候会触发,查看用了哪些el-table自带的方法
解决方案:
- el-table中添加 <el-table :row-key=“getKey”——未生效
getKey(row) {
return row.id;
},
2.确保tableList类型为[]——未生效
3. 用了toggleRowSelection(row);方法回显选中的数据,添加判断——找到原因,解决。
let row = this.deviceList.filter(item => item.deviceId == this.form.ledDeviceId)[0];
if (row) {
this.$refs.equipmentTable.toggleRowSelection(row);
}
本文讲述了在使用ElementUI的el-table组件时遇到的错误,原因是在没有设置row-key属性且tableList非空数组时触发了错误。提供了添加row-key属性和检查tableList类型的解决方案,以及通过toggleRowSelection方法的判断来修复问题。
1721





