方法有两种
-
header-cell-style 此种方法是直接返回样式
-
header-cell-class-name 只是返回一个class
element ui 官方文档 可详细阅读上面两种方法的用法
案例
1.header-cell-style
<el-table :data="datalist"
:header-cell-style="styleFunc"></el-table>
styleFunc({row,column,rowIndex, columnIndex}){
if('条件'){
return "color: #fff;background:red"
}
}
2.header-cell-class-name
<el-table :data="datalist"
:header-cell-class-name="classNameFunc"></el-table>
classNameFunc({row, column, rowIndex, columnIndex}){
if('条件'){
return classStyle
}
}
<style>
.classStyle{
//你需要的样式
color: #fff !important;
}
</style>