用到cell-style方法:
<el-table ref="table" :cell-style="tableRowStyle" :data="tableData" border >
js 注意:與平時表格數(shù)據(jù)不同搂橙,舉例數(shù)據(jù)需要循環(huán)
重點M!:foreach失效页衙,需要用for in L稀!
tableRowStyle({ row, column, rowIndex, columnIndex }) {
if (row.ceshi.length) {
if (columnIndex !== 0) {
console.log(row.ceshi, column, rowIndex, columnIndex, 'val.....')
columnIndex = columnIndex - 1
for (let index = 0; index < row.ceshi.length; index++) {
if (this.postList[columnIndex].value === row.ceshi[index].postId) {
return 'background:#F5F7FA;!important;'
}
}
}
}
},
簡單數(shù)據(jù)舉例:
tableRowStyle({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 0) {
return 'background:#F5F7FA;!important;'
},
ht背景色
<style lang='scss'>
.quiry{
.el-table th.el-table__cell{
background-color:rgb(128,100,162);
color: #fff;
}
}
</style>