<el-table ref="multipleTable"
:data="patentList" :row-key="getRowKey" @selection-change="handleSelectionChange"> // :row-key="getRowKey" 加一下这个
<el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column> //reserve-selection="true" 这个得加一下
......
</el-table>
watch: {
// 监听数据变化时候,改变选择
patentList(val){
val.forEach((item,i)=>{
this.multipleSelection.forEach((multItem,j)=>{
if(item.id==multItem.id){
this.$refs.multipleTable.toggleRowSelection(item,true);//这步操作是让 页面显示选中的数据
}
})
})
}
},
methods:{
getRowKey:function(row){
return row.id
},
handleSelectionChange(val) {
this.multipleSelection = val;
console.log(this.multipleSelection )
},
}
网友评论