本文介绍: eltable 修改多级表头背景色,利用组件自带属性headerrowstyle来完成,注意一定不要全局设置表头颜色,因为全局设置必须加!important,这样我们就无法覆盖了。

先看效果图: 

利用组件自带属性headerrowstyle来完成。注意一定不要全局设置表头颜色,因为全局设置必须加!important,这样我们就无法覆盖了。

项目有其他表格设置背景色,可以通过eltable添加这句话就可以了,一行代码也不费劲,:headercellstyle=”{background:’#fffaee‘}”

 <el-table ref="dateTable" :data="tableData" :header-cell-style="tableHeaderColor" border stripe>

 // 修改表头颜色
    tableHeaderColor ({ rowIndex, columnIndex }) {
      if (rowIndex === 0 && columnIndex === 0) {
        return { background: '#fffaee' }
      } else if (rowIndex === 0 && columnIndex !== 0) {
        return { background: '#FFBD7C', border: '0' }
      } else {
        return { background: '#fffaee' }
      }
    },

好啦,就酱紫吧,拜拜~~~~

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注