element-ui 中 el-table 的样式修改
头部header部分,以及表格行(tr)的样式修改
- 实现样式对应的代码:
<el-table
:data="tableData"
:header-cell-style="tableHeaderStyle"
:row-style="rowClass"
class="table_box">
</el-table>
// 相对应的方法
methods: {
tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
if (rowIndex === 0) {
return `
background-color: #051248;
color: #fff;
`;
}
},
rowClass(row) {
if ((row.rowIndex + 1) % 2 == 0) {
return { background: "#0F235D", color: "#B8C0EA" };
} else {
return { background: "#051248", color: "#B8C0EA" };
}
},
}