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

**`

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

`**

相关推荐
kyriewen7 小时前
我把最常踩的8个CORS跨域报错整理了一遍——第8个去年还不存在
前端·javascript
NeilCarmack11 小时前
Deepseek-harness增加桌面版端序列:第 2 讲 · spawn Electron:当前进程如何“交棒“
前端·javascript·electron
এ慕ོ冬℘゜14 小时前
使用 jQuery 动态渲染表格与状态切换
前端·javascript·jquery
智购科技自动售货机厂家15 小时前
2026自动售货机AI视觉识别优化:从YOLOv11n模型量化到RKNN部署的端侧推理工程实践~YH
javascript·人工智能·yolo·机器学习·计算机视觉·目标跟踪·perl
晓说前端15 小时前
TypeScript 核心语法应用 —— Vue 3 中的使用(下)
前端·javascript·typescript·类型系统
lancyu18 小时前
# Agent Loop:AI Agent 的唯一直心骨
开发语言·javascript·人工智能
半个落月19 小时前
JavaScript 单例模式详解:从唯一实例到按钮事件
javascript
weixin_BYSJ198720 小时前
springboot智慧公共交通系统---附源码51123
java·javascript·spring boot·python·django·flask·php
sir.山20 小时前
在 Vue 3 项目中使用 Mock 数据
前端·vue.js·vue3·vite