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

**`

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

`**

相关推荐
冴羽yayujs12 分钟前
JavaScript 9 个先有库再有 API 的故事
开发语言·javascript·ecmascript
m0_7510186618 分钟前
docker 安装 nginx
vue.js·nginx·docker
油丶酸萝卜别吃30 分钟前
JavaScript 深度合并函数 deepMerge 实现指南(附完整测试用例)
开发语言·javascript·测试用例
kyriewen32 分钟前
Copilot下个月按Token收钱,我算了一笔账:重度用户一年要多花3000块
前端·javascript·openai
zyl837211 小时前
3Dmol.js + Vue3快速上手
vue.js
镜宇秋霖丶1 小时前
2026.5.18@霖宇博客制作中遇见的问题
vue.js
w_t_y_y1 小时前
VUE3(二)VUE2和VUE3区别
前端·javascript·vue.js
阿明在折腾1 小时前
在浏览器里实现 PDF 合并与拆分:pdf-lib 实战指南
前端·javascript
不是山谷.:.1 小时前
Axios的【接口防抖 + 请求失败重试 + 弱网提示】三合一高阶版封装
前端·javascript·vue.js·笔记·elementui·typescript
超绝大帅哥1 小时前
babel降级|>, Object.groupBy
前端·javascript