ui效果如下
代码实现:
<el-table
ref="mulTip"
:data="tableData.resultList"
tooltip-effect="dark"
border
size='mini'
:cell-style="cellStyle"
:header-cell-style="{background:'#eef1f6',color:'#606266',borderColor:'white'}"
>
<el-table-column align="center" :width="item.width" :label="item.label" :prop="item.prop" v-for="item in tableData.columns" :key="item.sort"></el-table-column>
</el-table>
js代码
//这个索引可以自己去找关键字段在第几列,变成动态的
cellStyle ({ row, column, rowIndex, columnIndex }) {
if (row.result === '阴性' && columnIndex === 6) {
return 'color: #0CB618'
} else if (row.result === '阳性' && columnIndex === 6) {
return 'color: #EA1B29'
}
},