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 小时前
🚦 请三个 AI 考官给 RAG 打分:量化评估实战(下)
前端·javascript
阿坨7 小时前
灵感闪存卡:一款 Tampermonkey用户脚本
javascript·tampermonkey
朝朝辞暮i9 小时前
C++ 第 25 课:getter / setter + this
java·javascript·c++
蜗牛互联网9 小时前
Python接入Gemini 3.8 Flash实现票据视觉抽取与规则校验
java·javascript·网络·人工智能·python
易朵朵10 小时前
CSS 格式化上下文
css·vue.js
xieter11 小时前
【技术精选】深入浅出现代前端渲染与性能优化实践指南 (2026-10-04)
前端·javascript
xieter11 小时前
【硬核实战】TypeScript Compiler API: Preserving Child Node Narrowing in Reusable Type Guards 🔧 (2026-10-03)
前端·javascript
xieter11 小时前
【硬核实战】React 19 useFormStatus Returning False? I Built a SubmitButton That Fixes It (2026-10-03)
前端·javascript
雪芽蓝域zzs12 小时前
第6节:远程搜索弹窗(remote 模式),弹窗滚动加载分页
vue.js·elementui
paopaokaka_luck12 小时前
非遗文物数字化小程序(AI非遗问答、ONNX图像识别、协同过滤推荐、ECharts数据分析、非遗知识浏览与互动、文创商城订单闭环、文化活动报名签到、社区交流)
javascript·spring boot·mysql·数据分析·echarts·mybatis