Vue+Element-Ui 指定修改某一個cell的樣式


廢話不多說上代碼:

<template>
<el-table
        v-if="tableData.length > 0"
        :data="tableData"
        max-height="100%"
        style="width: 100%"
        :header-cell-style="{ background: '#BCD2EE' }"
        :cell-style="SetCellStyle"
      >
        <el-table-column
          prop="beginTime"
          align="center"
          label="時間"
          width="150"
        >
        </el-table-column>
        ... 省略N個column ...
</el-table>
</template>    
<script>
export default {
  name: "xxx",
  data() {
    return {
      cellStyle: {
        backgroundImage: "url(" + require("../assets/quan.png") + ")",
        backgroundRepeat: "no-repeat",
        backgroundSize: "42px,30px",
      },
    },
  methods: {
    mounted() {},
    
    SetCellStyle({ row, column, rowIndex, columnIndex }) {
      if (column.label == row.nine) {
        console.log(row);
        console.log(column);
        console.log(rowIndex);
        console.log(columnIndex);
        return this.cellStyle;
      }
    },
}
</script>

效果展示:

 努力學習中。。。


免責聲明!

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



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