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)
}
浙公网安备 33010602011771号