I have a problem
If the script executed, the result of console.log(date) is
Whereas from my script should the result
2019-10-01
2019-10-02
...
...
2019-10-31
why the results don't match?
if I choose next month, the results will also not match
解决方案
Updated for loop initialisation for(var i = 1; i <= totalDay; i++) {
and let date = moment().month(val.split('-')[1]-1).date(i).format("YYYY-MM-DD")
Now it works as expected
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
date: '2019-10-15',
id: 5
}),
methods: {
pickerUpdate: async function(val, id) {
let totalDay = moment(val, "YYYY-MM").daysInMonth()
console.log(totalDay)
for(var i = 1; i <= totalDay; i++) {
let date = moment().month(val.split('-')[1]-1).date(i).format("YYYY-MM-DD")
console.log(date)
}
},
},
})