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' }
  }
}

**`

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

`**

相关推荐
仨孩子的爹7 分钟前
CSS打印样式:字体族与行高在纸上的对照实测
vue.js
用户2763965765102 小时前
放弃 JWT 后,我给 FastAPI 游戏服务端手撸了一套 token session
javascript
用户84298142418103 小时前
从 JavaScript 到可运行的字节码 - ByteJS 使用指南
javascript
OpenTiny社区3 小时前
AI Agent场景组件库 TinyRobot v1.0 正式发布:一站式打造您的AI助手
vue.js·github
学以智用4 小时前
wangEditor V5 精简完整参考手册
javascript
用户298698530144 小时前
React 前端实现 Excel 与 CSV 互转:基于 WebAssembly 的浏览器端方案
javascript·react.js·excel
ruanno_top20 小时前
轮播每 3 秒自己翻页:键盘停不下来,读屏也不知道换了页
vue.js
1-1=020 小时前
Vue 3 模板语
前端·javascript·vue.js
风卿20 小时前
看着AI写代码太孤独了,来欣赏星云吧:一个DSH 装饰插件
前端·javascript