Element-UI中table组件设置树型表格序号

2020-04-02  本文已影响0人  wxb2dyj
先放效果:树型表格默认收起状态,展开后子表格也要获得序号,如下图。 image.png

方法:通过动态绑定属性 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,感谢原博主。

上一篇 下一篇

猜你喜欢

热点阅读