最近项目需要使表格字体变色,具体需求如下:

在表格中,分为2类,需要处理。
1、 template slot-scope="scope"
2、 直接写在label上的。el-table-column label="证件名称"
解决方法:
第一类、 简单粗暴的直接 v-if去判断
<template slot-scope="scope">
<font v-if="scope.row.certificateStatus === 2">通过</font>
<font v-else-if="scope.row.certificateStatus === 1" color="red">待审核</font>
<font v-else="scope.row.certificateStatus === 3" color="red">驳回</font>
</template>
第二类:
1、 在el-table加上:cell-style="cellStyle"。
2、 然后判断label
<el-tab :cell-style="cellStyle"></el-tab>
cellStyle(row, column, rowIndex, columnIndex) {
console.log(row);
if (
row.column.label == "完美状态" &&
row.row.certificateStatus == "1"
) {
return "color:red";
}
}