接上篇 连接后台数据

this.dataList 为后台返回的数据

formatDate 为当前面板上的日期(42个)

 

cellClassName: date => {
默认返回的是标准时间 转换为常用日期格式
          let formatDate = date.getFullYear() + '-' + (((date.getMonth() + 1) >= 10 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1))) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate())
          let nowDate = new Date()
获取当前时间
          let nowDateFormat = nowDate.getFullYear() + '-' + (((nowDate.getMonth() + 1) >= 10 ? nowDate.getMonth() + 1 : '0' + (nowDate.getMonth() + 1))) + '-' + (nowDate.getDate() >= 10 ? nowDate.getDate() : '0' + nowDate.getDate())
          将后台数据返回的时间和formatDate进行对比 取相同的添加样式 详细看findIndex
          let index = this.dataList.findIndex(item => item.date == formatDate)
          if (index == -1) return;
          if (formatDate >= nowDateFormat) return;
          return 'testClass' + this.dataList[index].data.status + ' testClass'
        }
这样就将后台返回的状态添加给了对应的日期

 

posted @ 2021-06-17 19:03  非自然数  阅读(48)  评论(0编辑  收藏  举报