element el-table表格表头某一列表头文字或者背景修改颜色

 效果如下

整体代码 ,具体方法在最下面!

    <el-table v-loading="listLoading" :data="sendReceivList"  element-loading-text="Loading" border fit ref="tableList"  :header-cell-class-name="addClass"  
      highlight-current-row @selection-change="handleSelectChange" :row-key="getRowKey">
   
    <el-table-column label="单位" align="center" width="60px">
        <template slot-scope="scope">
          <div>{{ scope.row.unit }}</div>
        </template>
      </el-table-column>
      
      <el-table-column label="期初结存" align="center"  >
      <el-table-column label="数量" align="center"   >
        <template slot-scope="scope">
          <div>{{ scope.row.preNum }}</div>
        </template>
      </el-table-column>
       <el-table-column label="平均单价" align="center"   >
        <template slot-scope="scope">
          <div>{{ scope.row.prePrice }}</div>
        </template>
      </el-table-column>
       <el-table-column label="金额" align="center"   >
        <template slot-scope="scope">
          <div>{{ scope.row.preUnitPrice }}</div>
        </template>
      </el-table-column>
      </el-table-column>
   <el-table-column label="本期入库" align="center"  >
      <el-table-column label="数量" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.rkNum }}</div>
        </template>
      </el-table-column>
       <el-table-column label="平均单价" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.rkUnitPrice }}</div>
        </template>
      </el-table-column>
       <el-table-column label="金额" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.rkPrice }}</div>
        </template>
      </el-table-column>
      </el-table-column>
     <el-table-column label="本期出库" align="center"  >
      <el-table-column label="数量" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.ckNum }}</div>
        </template>
      </el-table-column>
       <el-table-column label="平均单价" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.ckUnitPrice }}</div>
        </template>
      </el-table-column>
       <el-table-column label="金额" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.ckPrice }}</div>
        </template>
      </el-table-column>
      </el-table-column>
     <el-table-column label="期末结余" align="center"  >
      <el-table-column label="数量" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.postNum }}</div>
        </template>
      </el-table-column>
       <el-table-column label="平均单价" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.postPrice }}</div>
        </template>
      </el-table-column>
       <el-table-column label="金额" align="center"  >
        <template slot-scope="scope">
          <div>{{ scope.row.postUnitPrice }}</div>
        </template>
      </el-table-column>
      </el-table-column>
      <el-table-column align="center" label="出入库流水" fixed="right">
        <template slot-scope="scope">
          <el-button type="text" @click="jumpClick"   size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

主要看这!!!

<el-table :data="sendReceivList"  :header-cell-class-name="addClass"  
 methods: {
 
  addClass({ row, rowIndex, column, columnIndex }) {
      if (column.label == '数量'||column.label == '平均单价'||column.label == '金额') {
        return "whiteColor";
      } else {
        return 'huiColor'
      }
    },
  },


<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-table__header-wrapper th.whiteColor {
  background-color: white !important;
  color: red;
}
::v-deep .el-table__header-wrapper th.huiColor {
  background-color: #F5F7FA !important;
}

</style>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值