LWM

el-table在行单击时获取行的index – 源码巴士 (code84.com)

 

1、el-table中添加 row-class-name,绑定@row-click事件

<template>
<el-table
  id="step1"
  :data="list"
  :row-class-name="tableRowClassName"
  border
  @row-click="handleEdit"
>

……
</template>

2、给el-table中的每个row对象里添加index属性

tableRowClassName({ row, rowIndex }) {
    row.index = rowIndex;
},

3、行的点击事件

handleEdit(row, column, event) {
    console.log(row,row.index)
}

 

posted on 2023-01-26 21:15  Lwmm  阅读(1601)  评论(0编辑  收藏  举报