/* 可以做到在table组件数据变化时,动态绑定class */
<el-table
border
height="420"
:header-cell-style="{ background: '#ebf8f8' }"
:data="specList"
size="small"
:row-class-name="row => (row.row.checked ? 'check-row' : '')"
class="spec-table"
>
...
</el-table>
另外一种:
/* table组件数据变化后,表格不会重新渲染,class不会改变 */
<el-table
:data="tableData"
style="width: 100%"
:row-class-name="tableRowClassName">
...
</el-table>
methods: {
tableRowClassName({row, rowIndex}) {
if (row.checked) {
return 'warning-row';
}
}
}