- 在页面添加 :row-class-name=“tableRowClassName”
<el-table style="margin-top: 1rem;overflow: auto; " :data="goodsList" height="600"
:row-class-name="tableRowClassName" ref="tableRef" v-loading="loading">
</el-table>
- 在 script 内 调用方法
tableRowClassName
function tableRowClassName({ row, rowIndex }) {
if (selectItem.value == row.id) {
return 'success-row'
}
}
- 在 style 内设置自定义样式
.el-table .success-row {
--el-table-tr-bg-color: rgba(105, 191, 248, 0.6);
}