1.通过header-cell-style属性可以实现该需求
<el-table
v-loading="loading"
:data="tableData"
border
:header-cell-style="headerStyleEvent"
row-class-name="tableRowClassName"
>
</el-table>
2.通过索引寻找到对应的列
methods: {
headerStyleEvent({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 7 || columnIndex == 8) {
return 'background-color:#FFFF99'
} else if (columnIndex == 9 || columnIndex == 10) {
return 'background-color:#169BD5'
} else if (columnIndex == 11 || columnIndex == 12 || columnIndex == 13) {
return 'background-color:#669999'
} else if (
columnIndex == 14 ||
columnIndex == 15 ||
columnIndex == 16 ||
columnIndex == 17
) {
return 'background-color:#FF9900'
}
}
}