1、根据数据不同给行或单元格赋不同的class,主要使用如下回调函数
如单号行设为red_row,双号行设为yellow_row,代码如下:
tableRowClassName({
row,
rowIndex
}) {
if (rowIndex % 2 === 1) {
return 'yellow_row';
}
return 'red_row';
}
2、为不同的class设置不同的样式。
<style>
.el-table .el-table__body tbody .red-row {
background: #f56c6c;
}
.el-table .el-table__body tbody .yellow-row {
background: #daf56c;
}
</style>