props:{
title:{
type: String,
default:'' //默认值
},
}
watch: {
time:{
handler(n,o){
// 获取当前日期的时间戳
const todayTimestamp = new Date().getTime();
// 获取2023年7月30日的时间戳
const targetDateTimestamp = new Date(n).getTime();
// 计算时间差(以毫秒为单位)
const timeDiff = todayTimestamp - targetDateTimestamp;
// 将时间差转换为天数
const oneDayInMilliseconds = 24 * 60 * 60 * 1000;
this.daysDiff = Math.ceil(timeDiff / oneDayInMilliseconds)-1;
if(this.daysDiff == 0){
this.daysDiff = '今'
this.TT = '天'
}
},
deep:true,
immediate: true,
},
},