element-ui中更改表头颜色,通常情况下,ui框架都是会提供api文档来使用的,我们如何去更改表格中的表头文件呢,我们就需要使用到header-cell-style这个属性了,这个属性调用的是一个方法
属性名 header-cell-style
方法名 表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style。
方法属性 Function({row, column, rowIndex, columnIndex})/Object
在表格中调用
1 2 3 | <el-table :header-cell-style="getRowClass"> //表格内容…… </el-table> |
在methods中写下列方法
1 2 3 4 5 6 | getRowClass ({ rowIndex }) { if (rowIndex == 0) { return 'background:RGB(238,239,246)' } else { return '' } |
7