改变el-table样式

1、改变鼠标进入表格悬浮时颜色

/deep/ .el-table__body tr:hover>td{
  background-color: #39fcff;
}

一般情况下这个方法可以解决问题,如果不想影响所有表格给el-table 一个class名。

2、固定了右列并且表格单独有特殊色处理

a.有使用到特殊行颜色不同的处理,这个挺容易实现的(ps:如有不懂可以看一下官方文档-带状态表格)
/ / html

//html 
<el-table :row-class-name="tableRovClassName"></el-table>

// js
methods: {
    tableRowC1assName({row,rowIndex}){
        if (row.deployStatus ==O){
            return "warning-row"
        }else {
            return '';
        }
    }
}

b.灵活使用ecell-mouse-enter和ecell-mouse-leave(ps:如有不懂可以看一下官方文档-事件处理)

// html
<el-table
: row-class-name="tableRowClassName"
:ce1l-mouse-enter="mouseEnter"
cell-mouse-leave="mouseLeave"></el-table>
// js
methods: {
    mouseEnter(row,column,cell,event){
        官网查方法
    }
}

 //css
.table-hide-color>td{
    background: #fafafa!important;
}
.site-table .el-table_ body tr.hover-row>td{
    background : #fff;
}

3、表头背景修改

使用 :header-cell-style="headerStyle" 

headerStyle({row,column,rowIndex, columnIndex}){
      let cellStyle1;
      let cellStyle2;
      let cellStyle3;
      cellStyle1= "color: #fff;background:#027db4"
      if(columnIndex >= 0 && columnIndex < 14 && rowIndex===0){
        return cellStyle1;
      }
    },

4、修改每表格一行背景

使用  :row-class-name="tableRowClassName"

tableRowClassName({row, rowIndex}) {
          if (rowIndex === 0) {
              return 'warning-row';
          } else if (rowIndex === 1) {
              return 'color: #fff;background:#027db4';
          }
          return '';
      },

//css
/deep/ .el-table .warning-row {
      background-color: #027DB4;
      color: #fff;}

/deep/ .el-table .success-row {
        background: #f0f9eb;
    }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值