获取elementUI Table单击的一个单元格的列和行

获取elementUI Table单击的一个单元格的列和行

elementUI Table点击单元格获取该单元格的行和列。

1
2
3
<el-table :cell-class-name="tableCellClassName" @cell-click="cellClick">
...
</el-table>

1
2
3
4
5
6
7
8
9
10
11
methods:{
tableCellClassName({row, column, rowIndex, columnIndex}){//注意这里是解构
//利用单元格的 className 的回调方法,给行列索引赋值
row.index=rowIndex;
column.index=columnIndex;
},
cellClick(row, column, cell, event){
console.log(row.index);
console.log(column.index);
}
}

转载自:https://blog.csdn.net/KangTongShun/article/details/106003678

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×