//html
<el-table
:data="tableData"
style="width: 100%"
:cell-class-name="cellClassName"
@cell-click="handleClickCell">
</table>
//script
- 先利用单元格的className方法,给行列索引赋值
cellClassName({row, column, rowIndex, columnIndex}){
row.index = rowIndex;
column.index = columnIndex;
},
- 获取
//点击某个单元格
handleClickCell(row, column) {
console.log(row.index);
console.log(column.index);
},