ElementUI:el-table 判断某个时间超过当前时间行标红

功能总结:
1.elementUI表格给某一行添加背景颜色
2.如何js判断两个时间大小

**

表格代码:

**

复制代码
   <el-table
        ref="$table" :data="tableData"  row-key="id" 
        :header-cell-style="{ 'text-align': 'center' }" :cell-style="cellClassName"
      >
   </el-table>

备注:通过:cell-style属性给表格添加背景颜色

复制代码
function cellClassName({ row }) {
  var currentDate = new Date();
  var currentDateStr = currentDate.getFullYear() + '-' + (currentDate.getMonth() + 1) + '-' + currentDate.getDate();  // 当前时间的时间戳
  if (new Date(currentDateStr).getTime() > new Date(row.completeDt).getTime()){
    return { 'background-color': 'red', 'text-align': 'center' }
  }else{
    return { 'text-align': 'center' }
  }
}

**`

逻辑:把时间转化成时间戳来判断两个时间的大小

`**

相关推荐
Lao乾妈官方认证唯一女友:D6 小时前
通过plasmo的wallet扩展添加新钱包
javascript·web3·区块链
ALKAOUA6 小时前
力扣面试150题刷题分享
javascript·笔记
迪巴拉15256 小时前
基于Vue与Spring Boot+Open Cv的智慧校园考勤系统
前端·vue.js·spring boot
swipe6 小时前
JavaScript 对象与属性描述符:从原理到实战
前端·javascript·面试
&活在当下&6 小时前
Vue3 h函数用法详解
前端·javascript·vue.js
小贵子的博客7 小时前
(vue3错误处理)has naming conflicts with other components, ignored.
前端·javascript·vue.js
西西学代码7 小时前
Flutter---路由与导航
服务器·前端·javascript
跟着珅聪学java8 小时前
electron 安装教程
javascript·arcgis·electron