[Vuejs]-How can I get month moment js in loop on the vue?

0👍

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)
      }

    },
  },

})

codepen here: https://codepen.io/chansv/pen/dyyXYgQ?editors=1010

Leave a comment