微信截图_20190524183613.png
1、
<el-table
ref="multipleTable"
:data="tableData3"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
@row-click="handleclick"
:row-style="rowClass" //核心项
row-key="id"
>
2/
data(){
return {
selectRow: [],
multipleSelection:[]
}
}
3/
watch: {
multipleSelection(data) { //存储选中的row
this.selectRow = [];
if (data.length > 0) {
data.forEach((item, index) => {
this.selectRow.push(item.id);
});
}
}
},
4/
methods: {
rowClass({ row, rowIndex }) {
if (this.selectRow.includes(row.id)) {
return { "background-color": "rgba(185, 221, 249, 0.75)" };
}
},
handleSelectionChange(val) {
this.multipleSelection = val;
console.log(val, "多选");
},
}