ElementUI 中 el-table 获取当前选中行的index

第一种方法:将index放到row数据中

首先,给table加一个属性::row-class-name="tableRowClassName"

然后定义tableRowClassName函数:(tableRowClassName可以自己改名)

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

然后给表格添加:@row-click = "onRowClick"

onRowClick (row, event, column) {
    this.currentRowIndex = row.row_index;
}

这时,属性:currentRowIndex存的就是当前选中行的index了

猜你喜欢

转载自www.cnblogs.com/wbyixx/p/11949875.html