方法:通过动态绑定属性 row-class-name
template如下:
<el-table :data="tableData3" height="550" style="width: 100%;background: transparent" @row-click="device_detail" :row-class-name="rowClassName">
<el-table-column prop="id" label="序号" width="180"></el-table-column>
</el-table>
script如下:
rowClassName({row, rowIndex}) {
//把每一行的索引放进row.id
row.id = rowIndex+1;
}
引用自https://blog.csdn.net/weixin_39520629/article/details/88821693,感谢原博主。