element表格table点击添加背景色

效果图:

先添加两个事件:

 

然后需要保存行和列的信息,然后在 tableCellStyl对象里判断,等于哪一行哪一行就变色,否则就是白色

    cellclick(row, column) {
      this.row = row;
      this.column = column;
    },

    tableCellStyle(row) {
      if (
        this.row === row.row
      ) {
        return "background-color:#f7f9fa;";
      } else {
        return "background-color:#fff;";
      }
    },

猜你喜欢

转载自blog.csdn.net/weixin_52691965/article/details/126300045