element table标题加必填标识

448 阅读1分钟

1,需要在el-table加入 :header-cell-class-name="must"

<el-table
    class="mt18"
    :data="addTable"
    border
    ref="chooseMulTip"
    :header-cell-class-name="must"
>

2,columnIndex 是下标 在methods 添加方法 must

must({row, rowIndex, column, columnIndex}) {
    if (columnIndex == 1 || columnIndex == 3 || columnIndex == 4) {
        return 'must';
    }
},

3,css 里面

/deep/ .el-table table th.must div:before {
    content: '*';
    color: red;
}