关于element-ui中el-table组件的序号问题?

场景:列表的第一列为序号,为保护数据信息,防止恶意爬虫,不能把后端给的id直接显示想到这里;
实现序号加一

解决:通过动态绑定属性 row-class-name 。

templete中:

<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>

methods中:

rowClassName({
    
    row, rowIndex}) {
    
    
    //把每一行的索引加一放进row.id
    row.id = rowIndex+1;
}

猜你喜欢

转载自blog.csdn.net/cst522445906/article/details/123333662