<el-table
:data="arrList"
border
:cell-style="addClass"
style="width: 100%;"
:max-height="tableHeight"
:span-method="arraySpanMethodActual">
</el-table>
1. el-table中增加 :cell-style="addClass" 属性
2. js中使用 addClass 这个方法,想怎么加样式就怎么加
addClass({row,column,rowIndex,columnIndex}){
if(row[2].includes('合计')){
return columnIndex == 1 ? 'background: #F5F7FA;font-weight: bold;' : 'background: #F5F7FA;';
}
if(columnIndex == 0) {
return 'background: #F5F7FA;';
}
},
3.固定表头用的是 :max-height="tableHeight" 这个属性,加上高度一块使用
computed: {
contentHeight: {
get () { return this.$store.state.common.contentHeight }
},
tableHeight(){
var height = this.contentHeight - 230;
return height + ""
}
},