需求:
在表格添加一个index属性来操作表格
解决方案:
在表格上面添加:row-class-name,通过这个方法为每一行设置index
实现:
html
<el-table :data="tableData" border style="width: 100%" :row-class-name="tableRowClassName">
</el-table>
javascript
methods: {
//row-class-name添加下标
tableRowClassName(row, index) {
row.row.index = row.rowIndex;
},
}