问题
点击”仅显示已选择“时,toggleRowSelection()无效。
原因
可能是在修改后的table的数据里,有什么和之前不一样了。导致匹配不到对应的列。
解决方案
使用find或者别的数组检索函数,找到table里的那一条数据,而不是直接用row。
this.$refs.table.$refs.table.clearSelection();
this.$nextTick(() => {
if (this.selectList.length > 0) {
this.selectList.forEach(row => {
this.$refs.table.$refs.table.toggleRowSelection(this.tableInfo.data.find((item) => {
return row.id == item.id;
}),
true);
});
} else {
this.$refs.table.$refs.table.clearSelection();
}
this.$forceUpdate()
})