element changes the table header, row, and specified cell style

element changes the table header, row, and specified cell style

Change the style of the table

Use header-cell-style attributes, which can be functions or objects

  1. Function writing
<!-- html -->
<el-table :header-cell-style="rowClass"></el-table>
//在method里面写上方法
rowClass({
    
     row, rowIndex}) {
    
    
    console.log(rowIndex) //表头行标号为0
    return 'background:red'
}

2. Object writing

<!-- html -->
<el-table :header-cell-style="{background:'red'}"></el-table>

Change the style of a cell in the table

1. Function writing

<!-- html -->
<el-table :header-cell-style="cellStyle"></el-table>
//在method里面写上方法
cellStyle({
    
    row, column, rowIndex, columnIndex}){
    
    
    if(rowIndex === 1 && columnIndex === 2){
    
     //指定坐标
        return 'background:pink'
    }else{
    
    
        return ''
    }
}

2. Object writing

<!-- html -->
<el-table :cell-style="{background:'pink'}"></el-table>

Guess you like

Origin blog.csdn.net/weixin_46034375/article/details/108960076