0👍
✅
You set the selectedDate to moment(new Date())
every time you run this method. So it always goes back one month based on today.
You need to keep the state of selectedDate, something like this should work:
data() {
return {
selectedDate: undefined
}
},
mounted() {
this.selectedDate = moment(new Date())
},
methods: {
prevMonth() {
let futureMonth = moment(this.selectedDate.subtract(1, 'month')).startOf('month')
this.selectedDate = futureMonth;
......
})
}
}
Source:stackexchange.com