版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
<el-table ref="voiceTable"
:data="tableData"
@select="getSelectData"
@select-all="getAllSelectedData"
:header-cell-class-name="setCheckallStyle"
:row-style="rowClass"> // 重点在这里
/**
* 选中/取消某行时改变其背景色
*/
rowClass({row, rowIndex}) {
if (this.finInvoiceUuidList.includes(row.uuid)) { //①
return { "background-color": "rgba(185, 221, 249, 0.75)" };
} else {
return '';
}
}
①:每行数据都有一个业务属性uuid,而且是全局唯一。finInvoiceUuidList用于保存已选中行对应的uuid。