export default {
data() {
return {
previousDates: [],
}
}
mounted() {
this.GetDateStr(0);
for (let i = 4; i >= 0; i–) {
this.GetDateStr(-i);
let a = this.GetDateStr(-i);
this.previousDates.push(a);
}
},
methods: {
GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1 < 5 ? ‘0’ + (dd.getMonth() + 1) : dd.getMonth() + 1; //获取当前月份的日期,不足10补0
var d = dd.getDate() < 5 ? ‘0’ + dd.getDate() : dd.getDate(); //获取当前几号,不足10补0
return y + ‘-’ + m + ‘-’ + d;
// this.item.forEach(item => {
// this.GetDateStr.push(item);
// });
},
},
history(data){
if (date.length === 0) {
date = this.previousDates;
}
}
}