element-ui 表格获取单元格行和列的索引


                

 通过:cell-class-name='getCellIndex'先把索引绑定到row下,点击实获取索引

cellClick: function (row, column, cell, event) {
  // console.log(row, column, cell, event);
  // var index = $(cell).index();
  this.forecastTime = parseFloat(column.label);
  this.size = parseFloat(row.size);
  // console.log(index, this.forecastTime);
  this.rowIndex = row.index;
  this.columnIndex = column.index;
},
getCellIndex: function ({ row, column, rowIndex, columnIndex }) {
  row.index = rowIndex;
  column.index = columnIndex;
},
setCellStyle: function ({ row, column, rowIndex, columnIndex }) {
  if (rowIndex === this.rowIndex && columnIndex === this.columnIndex) {
    return { "background-color": "#009221" }
  }
},

 

你可能感兴趣的:(element-ui)