el-table
中添加 row-class-name
,绑定@row-click
事件
<el-table:data="list":row-class-name="tableRowClassName"@row-click="handleRowClick"
>
</el-table>
给el-table中的每个row对象里添加index属性
tableRowClassName({ row, rowIndex }) {row.index = rowIndex;
},
点击
handleRowClick(row, column, event) {console.log(row,row.index)
}
参考:
el-table在行单击时获取行的index