element获取cell-click点击的索引(第几行第几列)

//html

<el-table
    :data="tableData"
    style="width: 100%"
    :cell-class-name="cellClassName"
    @cell-click="handleClickCell">
</table>

//script

  1. 先利用单元格的className方法,给行列索引赋值
cellClassName({row, column, rowIndex, columnIndex}){
    row.index = rowIndex;
    column.index = columnIndex;
},
  1. 获取
//点击某个单元格
handleClickCell(row, column) {
	console.log(row.index);
	console.log(column.index);
},

参考:https://blog.csdn.net/z591102/article/details/111386616

你可能感兴趣的:(项目问题小记,javascript,前端,es6)