ElementUi中table组件使用row-class-name修改指定行

ElementUi中table组件使用row-class-name修改指定行

使用方法

//我这里使用的rowName这个方法名
:row-class-name="rowName" 
 <el-table v-loading="loading" :data="dataList" :row-class-name="rowName">

 </el-table>


  
methods: {
  rowName({row, column, rowIndex, columnIndex}) {
    let day = this.getNumberOfDays(row.createTime, new Date())
    //时间差大于等于7天改变颜色
    if (day>=7){
      return 'rowName'
    }
  },

  //获得天数
  getNumberOfDays(startDate,endDate){
     //startDate:开始日期,endDate结束日期
     var a1 = Date.parse(new Date(startDate));
     var a2 = Date.parse(new Date(endDate));
     var day = parseInt((a2-a1)/ (1000 * 60 * 60 * 24));//核心:时间戳相减,然后除以天数
     return day
  }

}

<style scoped>
   /deep/ .el-table .rowName {
      background: pink !important;
      color: #070707
   }
</style>

相关推荐

  1. ElementUitable使用row-class-name修改指定

    2024-01-04 14:36:04       64 阅读
  2. elementUI Table点击取当前索引

    2024-01-04 14:36:04       43 阅读
  3. React——classsetState修改state

    2024-01-04 14:36:04       45 阅读
  4. 【sass】 使用 /deep/ 修改 elementUI 样式报错

    2024-01-04 14:36:04       47 阅读
  5. elementUI库样式修改整理

    2024-01-04 14:36:04       43 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-04 14:36:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-04 14:36:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-04 14:36:04       87 阅读
  4. Python语言-面向对象

    2024-01-04 14:36:04       96 阅读

热门阅读

  1. Qt的三大机制(面试)

    2024-01-04 14:36:04       51 阅读
  2. 【嵌入式——C语言】动态内存申请

    2024-01-04 14:36:04       74 阅读
  3. LeetCode每周五题_2024/01/01~2024/01/05

    2024-01-04 14:36:04       58 阅读
  4. MATLAB --- dlmread( )函数的用法

    2024-01-04 14:36:04       67 阅读
  5. clickhouse-client INSERT CSV/TSV时跳过错误行

    2024-01-04 14:36:04       58 阅读
  6. Linux中经常使用的相关命令

    2024-01-04 14:36:04       61 阅读
  7. elasticsearch7.17.9两节点集群改为单节点

    2024-01-04 14:36:04       62 阅读