element-ui table 点击获取当前行索引

在el-table上添加:row-class-name和@row-click

<el-table :row-class-name="tableRowClassName" @row-click = "onRowClick">

js方法:

tableRowClassName ({row, rowIndex}) {
   //把每一行的索引放进row
   row.index = rowIndex;
},
onRowClick (row, event, column) {
   //点击获取索引
  const index = row.index;
  console.log(index)
}
发布了12 篇原创文章 · 获赞 2 · 访问量 392

猜你喜欢

转载自blog.csdn.net/qq_42739199/article/details/105134761