获取elementUI表格的某一个单元格的列和行
使用@cell-click可以得到四个参数
参数顺序是row, column, cell, event
这里的column,其实是cell,得到的是该行的html元素
打印row[column.property]
才有值
至于获取行列的索引,可以这样
<!--html-->
<el-table :cell-class-name="tableCellClassName" @cell-click="cellClick">
...
</el-table>
//js
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);
}
}