element-ui table組件設置背景顏色透明


搗鼓了好長時間;總結如下幾個注意點

1.重寫樣式要加(>>>或者/deep/),不然不會生效

2.th ,tr都有背景顏色,都要重寫,

廢話不多說,粘貼代碼:

<template>
    <div class="table-wrapper">
     <template>
  <el-table :row-style="getRowClass" :header-row-style="getRowClass" :header-cell-style="getRowClass" 
    :data="tableData"
    style="width: 1200px">
    <el-table-column
      label="序號"
      prop="list"
      width="88">
    </el-table-column>

    <el-table-column
      label="園區/監管倉名稱"
      prop="name"
      width="180">
    </el-table-column>

    <el-table-column
      label="類型"
      prop="type"
      width="180">
    </el-table-column>

    <el-table-column
      label="創建人"
      prop="creator"
      width="180">
    </el-table-column>

    <el-table-column
      label="創建時間"
      prop="data"
      width="180">
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini" type="text"
          @click="handleEdit(scope.$index, scope.row)">修改</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
    
    
    </div>
</template>


<script>


export default {
    name: 'warehouse-manage',
    data() {
      return {
        tableData: [{
          list: '1',
          name: '福田保稅區',
          type: '園區',
          creator:'張三',
          data:'2020-02-09 15:05:24'
        }, {
          list: '2',
          name: '福田保稅區',
          type: '園區',
          creator:'張三',
          data:'2020-02-09 15:05:24'
        }, {
          list: '3',
          name: '福田保稅區',
          type: '園區',
          creator:'張三',
          data:'2020-02-09 15:05:24'
        },]
      }
    },
    methods: {
         getRowClass({ row, column, rowIndex, columnIndex }) {
                return "background:#3f5c6d2c;";
            },
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      }
    }
  }
</script>
<style lang="less" scoped>
 .table-wrapper /deep/ .el-table--fit{
        padding: 20px;
}
 .table-wrapper /deep/  .el-table, .el-table__expanded-cell {
    background-color: transparent;
}

 .table-wrapper /deep/ .el-table tr {
    background-color: transparent!important;
}
 .table-wrapper /deep/  .el-table--enable-row-transition .el-table__body td, .el-table .cell{
    background-color: transparent;
}

</style>

效果圖如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM