我已经建立了一个显示日期表和相应日期的日历,我想添加在月份之间更改的功能。我在这里制作的方法确实“有效”。当我单击具有此功能的按钮时,它可以追溯到一个月前。但只有一次,这是因为 selectedDate 没有更新,所以当我尝试使用我注释掉的 console.log(selectedDate) 进行调试时,它仍然打印今天的日期。希望有人能在这里帮助我
methods: {
prevMonth() {
var selectedDate = moment(new Date());
let futureMonth = moment(selectedDate.subtract(1, 'month')).startOf('month')
selectedDate = futureMonth;
//return console.log(selectedDate)
this.days = [...Array(futureMonth.daysInMonth())].map((_, i) => {
return {
date: futureMonth.clone().add(i, "day"),
workhours: Math.floor(Math.random()*10),
overtime: Math.floor(Math.random()*10),
flextime: 0,
sickness: 0,
vacation: 0,
}
})
}
}
波斯汪
手掌心
随时随地看视频慕课网APP
相关分类