日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

element-plus 字體變色之cell-style

作者:慕白Lee 更新時間: 2023-09-18 編程語言

目錄

一 、需求

二、方法之cell-style

1 、cell-style

2 、表格綁定cell-style屬性

3 、數據操作

三 、方法之el-tag

1 、el-table-column

2、方法eachColor(){}


一 、需求

根據列表列值的不同顯示不同顏色

二、方法之cell-style

1 、cell-style

cell-style 單元格的 style 的回調方法,也可以使用一個固定的 Object 為所有單元格設置一樣的 Style。 Function({row, column, rowIndex, columnIndex})/Object
  • row:當前行
  • columnIndex:?列下標

2 、表格綁定cell-style屬性

        <el-table
          :data="tableData"
          :row-style="rowState"
          :cell-style="cellStyle"
          style="width: 100%"
        >

3 、數據操作

const cellStyle= ({ row, column, rowIndex, columnIndex })=> {
  // 狀態列字體顏色
  if (row.level >2 && columnIndex === 8) {
        return {'color': 'red'}; //方法1
        return "color: #FF0000"; //方法2
    }
}

三 、方法之el-tag

1 、el-table-column

    <el-table-column
      label="姓名"
      width="180">
      <template slot-scope="scope">
          <el-tag :type="eachColor(scope.row.level)">{{
            scope.row.level
          }}</el-tag>
        </el-popover>
      </template>
    </el-table-column>

2、方法eachColor(){}

    eachColor(level) {
      if (level == "5") {
        return "danger";
      }
      if (level == "4") {
        return "warning";
      }
      if (level == "3") {
        return "info";
      }
      ...
    },

有用請點贊,養成良好習慣!

疑問、交流、鼓勵請留言!

原文鏈接:https://libusi.blog.csdn.net/article/details/129655650

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新