本文介绍: 要获取Element UI中eltable中每一行index并将其传递方法可以使用eltable中提供的rowindex属性

获取Element UI中el-table中每一行index并将其传递方法可以使用el-table中提供的rowindex属性

<el-table @row-click="handleRowClick">
</el-table>
...
methods: {
  handleRowClick(row, event, column) {
    const rowIndex = event.target.parentNode.rowIndex - 1;
    ...
  }
}
<el-table-column label="操作">
  <template slot-scope="scope">
    <el-button @click="handleClick(scope.$index)">点击</el-button>
  </template>
</el-table-column>
...
methods: {
  handleClick(rowIndex) {
    ...
  }
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注