简体   繁体   中英

Vuetify.js and date-picker watch doesn't trigger on month

Running Vue.js and Vuetify.js .

I'm testing the data-picker and the watch method for triggering events on change of month. However, it only seems watch is noticing change of year , and not month .

HTML

<div id="app">
  <v-app>

    <v-date-picker ref="picker" v-model="date" :picker-date.sync="pickerDate" type="month"></v-date-picker>

  </v-app>
</div>

JS:

new Vue({
  el: "#app",
  data() {
    return {
      pickerDate: null,
      date: null,
    };
  },
  watch: {
    pickerDate(val) {
      console.log(val)
    }
  }
});

Codepen example shown here: https://codepen.io/alfredballe84/pen/varGWe?editors=1111

You should watch date not pickerDate but it's will trigger yyyy-mm

  new Vue({
      el: "#app",
      data() {
        return {
          pickerDate: null,
          date: null,
        };
      },
      watch: {
        date(val) {
          console.log(val)
        }
      }
    });


I solved your problem by changing the v-model="date"

to:

v-model="pickerDate"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM