首页 前端 正文
  • 前端
  • 本文约218字,阅读需1分钟
  • 895
  • 0

element-ui根据表格数据的值,设置单元格的颜色

需求:对表格中为0 的单元格进行标红处理

解决:cell-class-name

html:

<el-table border
        ref="saleBill"
        :data="saleBill"
        :cell-class-name="cellClassName">
</el-table>

Js:

//methods
cellClassName({row, column, rowIndex, columnIndex}){
    if((column.property == 'pack_dj' || column.property == 'pack_sl' || column.property == 'pack_order_sl') && row[column.property] <= 0 ){
        return 'zeroClass'
    }
}

CSS:

.zeroClass{
    color: red;
    font-weight: bold;
}

 

评论
更换验证码
友情链接