1.el-table标签的header-cell-style给指定的表头添加样式
:header-cell-style="getRowClass"
getRowClass ({ row, column, rowIndex, columnIndex }) {
if ((rowIndex === 0 && columnIndex === 0) || (rowIndex === 1 && (columnIndex === 0 || columnIndex === 1))) {
return 'background:#c90a5b;color:#fff;text-align:center;font-size:15px;font-weight:550;';
} else {
return '';
}
}
rowIndex===0是第一行,columnIndex===0是第一列。 return ' css样式 '
2. el-table标签的:span-method合并单元格,不包含表头
:span-method="rowSpanMethod"
if里面可以自定义,return[0,0]表示不合并。return[行数,列数]
rowSpanMethod({ row, column, rowIndex, columnIndex }) {
/**
* 表格合并
* row 表格每一行的数据
* column 表格每一列的数据
* rowIndex 表格的行索引,不包括表头,从0开始
* columnIndex 表格的列索引,从0开始
*/
if (this.areaShow || this.teamShow) {
if (columnIndex === 0) {
if (rowIndex % areaAndTeamRowCount === 0) {
return [areaAndTeamRowCount, 1];
} else {
return [0, 0];
}
}
}
}
3. el-table标签的:cell-style给特定表格添加样式 ,return cellStyle + ' css样式'
:cell-style="cellStyle"
cellStyle({ row, column, rowIndex, columnIndex }) {
if (diffRow === 0 && rowIndex % temCount === 0) {
if (cellValue < this.standardParameter.stoveRunCount) {
return cellStyle + 'color:#f00;';
}
}
}