效果如图:
html:
<el-table
class="box"
:data="tableData"
:height="height"
tooltip-effect="dark"
:row-style="selectedHighlight"
@selection-change="handDrawer"
>
methods:
selectedHighlight ({ row, rowIndex }) {
if (this.selectRow.includes(rowIndex)) {
return {
'background-color': '#15499A'
}
}
},
// 获取勾中表单
handDrawer (val) {
this.buttonList = val
},
watch:
watch: {
buttonList (data) {
this.selectRow = []
if (data.length > 0) {
data.forEach((item, index) => {
this.selectRow.push(this.tableData.indexOf(item))
})
}
}
},
亲测有效!