Vue Element-UI Table点击某一行,将该行背景色改变 超级简单

 在你的页面的table里面开启element table 行高亮选项: highlight-current-row

<el-table
        :data="tableData"
        style="width: 11%;margin-left: 1px;margin-top: 1px;padding-top: 110px;font-size: 16px;height: 100%"
        highlight-current-row
       >
        <el-table-column
          prop="name"
          label="相册名称"
          width="190">
        </el-table-column>
</el-table>

 然后在style 里面设置全局样式:

 /* 用来设置当前页面element全局table 选中某行时的背景色*/
  .el-table__body tr.current-row>td{
    background-color: #ff784a !important;
     color: #fff;
  }

 

拓展:默认设置选中第一行table

 <el-table
        :data="tableData"
        style="width: 190px;margin-left: 1px;margin-top: 1px;padding-top: 110px;font-size: 16px;height: 100%"
        highlight-current-row   //高亮显示
        @row-click="albumClick"
        ref="multipleTable"   //给table设置ref=‘multipleTable’
      >
        <el-table-column
          id="id"
          prop="name"
          label="名称"
          width="190">
        </el-table-column>
</el-table>
     //从后台拿到数据直接取this.privateData[0]第一条
     this.$refs.multipleTable.setCurrentRow(this.privateData[0],true)

在你渲染表格数据的方法里面写,或者是你获取数据的地方写

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值