如何给el-table中的行添加class

el-table里有这么一个属性row-class-name,是一个回调函数,可以给el-table__row加class。

举个栗子:

template

<el-table :data="dataTable" border style="width: 100%" :row-class-name="tableRowClassName">

script

 1 methods: {
 2     // 已选择渲染样式
 3     tableRowClassName (row, index) {
 4       if (row.operation) {
 5         return 'info-row'
 6       } else {
 7         return ''
 8       }
 9     }
10     }

style

<style>
.el-table .info-row{
  background: #5CB85C;
}
</style>

  

  

猜你喜欢

转载自www.cnblogs.com/janney/p/9708228.html