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

**`

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

`**

相关推荐
用户261245834016110 分钟前
vue学习路线(11.watch对比computed)
前端·vue.js
gnip20 分钟前
markdown预览自定义扩展实现
前端·javascript
G等你下课38 分钟前
AJAX请求跨域问题
前端·javascript·http
阑梦清川39 分钟前
Java后端项目前端基础Vue(二)
vue.js
爱编程的喵42 分钟前
JavaScript闭包深度解析:从作用域到实战应用
前端·javascript
ITfeib44 分钟前
Flutter
开发语言·javascript·flutter
雪碧聊技术2 小时前
深入解析Vue中v-model的双向绑定实现原理
前端·javascript·vue.js·v-model
打不着的大喇叭2 小时前
uniapp的光标跟随和打字机效果
前端·javascript·uni-app
Sun_light3 小时前
6个你必须掌握的「React Hooks」实用技巧✨
前端·javascript·react.js
爱学习的茄子3 小时前
深度解析JavaScript中的call方法实现:从原理到手写实现的完整指南
前端·javascript·面试