【el-table】设置行变色,以及鼠标移入的时候保持背景色不变
1、根据条件设置行变色,这个官网上也有示例,没啥难的,直接贴代码了
<el-table
:data="navList"
:row-class-name="tableRowClassName"
:cell-style="tableCellstyle"
>
tableRowClassName({ row, rowIndex }) {
if (row.Flag == 'Y') {
return 'changeBcg'
}
return ''
},
/deep/.el-table {
.changeBcg {
background: #fff2cc;
}
}
2、设置好背景色后发现,每次鼠标移入到变色的行上面,背景色就会变成灰色,要求是移入也要是变过色的背景色
tableCellstyle({ row, rowIndex }) {
if (row.Flag == 'Y') {
return 'background: #fff2cc'
}
return ''
},