需求: 列表中的截止日期的前三个月的日期跟当天日期进行比较,大于等于当天日期字体变红,否则黑色
效果图

<template slot-scope="scope">
<span class="timedateblock" v-if="scope.row.outTime">{{ scope.row.expirationDate }}</span>
<span class="timedatered" v-else>{{ scope.row.expirationDate }}</span>
</template>
------------------------------------------------------------------------------------------
async getlist() {
let req = {
page: this.page,
limit: this.limit,
parkId: this.parkId,
industryType: this.industryType,
enterpriseName: this.enterpriseName,
};
let list = await dossier.emengercyList(req);
let res = list.page.list;
====================================================================================
for (let i = 0; i < res.length; i++) {
const element = res[i];
element.outTime = true;
if (element.expirationDate) {
element.outTime = this.checkTime(element.expirationDate);
}
}
=====================================================================================
this.tableData = res;
this.total = list.page.totalCount;
},
=======================================================================================
checkTime(datetime) {
let myDate = new Date(datetime);
let year = myDate.getFullYear();
let lastM = myDate.getMonth() + 1;
let lastD = myDate.getDate();
if (lastM > 3) {
lastM = lastM - 3;
} else {
year = year - 1;
lastM = lastM + 12 - 3;
}
let startData = new Date(year + '-' + lastM + '-' + lastD + ' 00:00:00').getTime();
let nowtime = new Date(parseTime(new Date(), '{y}-{m}-{d} 00:00:00')).getTime();
return Number(startData) > Number(nowtime);
},
=======================================================================================