elementui table checkBox 多选表格 从列表进详情,看到该条信息之前选择的几项数据
info() {
// 这个是获取详情数据的接口
var a;
this.get("/business/label/" + this.id).then((res) => {
console.log(res);
if (res.code == 200) {
// 上图右边的数据列表
this.SelectedPersonnel = res.data.membersList;
// 循环 用两边数据都有的key值 取到左边那列 对应的那条数据
for (let i = 0; i < this.SelectedPersonnel.length; i++) {
for (let j = 0; j < this.tableData.length; j++) {
if (
this.SelectedPersonnel[i].userId == this.tableData[j].userId
) {
a = this.tableData[j];
// 最重要的就是这个,在elementui 官网有这个方法,让这行的状态为true 选中
this.$refs.multipleTable &&
this.$refs.multipleTable.toggleRowSelection(a, true);
}
}
}
}
});
},
// this.tableData 是左边那列可以选择的数据
// 因为这个是编辑,所以也要有左边可以选择的,方便再增加
弄这个 花了挺长时间的,有朋友说是那个table 的row-key属性,事实证明,跟row-key 一点关系也没有。。 说实话 elementui 的坑挺深的 。。。。