ElementUI改變表格顏色的方法 -- cell-class-name

  • 話不多說直接代碼:
<el-table :data="tableData3" style="width: 100%" :cell-class-name="changeCellStyle">
      <el-table-column fixed type="index" width="50">
      </el-table-column>
      <el-table-column fixed prop="name" label="名稱" width="80">
      </el-table-column>
      <el-table-column prop="date" label="上榜日" width="80">
      </el-table-column>
 </el-table>
 methods: {
      changeCellStyle({row, column, rowIndex, columnIndex}) {
      //第八列添加 red 類
        if(columnIndex == 7){
          return 'red'
        }
        //某一行其中的一個(gè)變量applies值如果大于0,并且在第六列,即確定一個(gè)具體的單元格需要確定行和列
        if(parseFloat(row.applies) >0 && columnIndex == 5){
          return 'red'
        }
       }
      }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容