给 el-table 的 cell-style 属性绑定方法:
<el-table
:data="tableData"
:cell-style="cellStyle"
border
>
...
</el-table>
// 在 methods 中定义方法:
cellStyle(row) {
// console.log(row);
if (
row.row.syncFlag === "失败" && row.column.label != "操作"
) {
return "background:#F25039;color:white";
}
},
表格表头数据:
实现效果: