1 2 3 4 5 6 7 8 9 10 11 |
<el-table :data="tableData" :row-class-name="rouClassNameFn" @row-click = "onRowClick" style="width: 100%"> <el-table-column prop="date" label="日期" width="180"> </el-table-column> </el-table> |
首先把index通过row-class-name灌注到数据数组中,rouClassNameFn({row,rowIndex}) 然后再获取就可以了
1 2 3 4 5 6 7 |
rouClassNameFn({row, rowIndex}) { //把每一行的索引放进row row.index = rowIndex; }, onRowClick (row, event, column) { console.log(row) } |