VueJS reactive Date object VueJS reactive Date object vue.js vue.js

VueJS reactive Date object


You are modifying the date object in place in which case Vue can not detect the changes, create a new date object instead:

https://jsfiddle.net/13gzu8xs/1/

new Vue({  el: "#app",  data: {    date: new Date()  },  methods: {    inc () {      this.date.setDate(this.date.getDate() + 1)      this.date = new Date(this.date)     //  create a new date and assign to this.date        },    dec () {      this.date.setDate(this.date.getDate() - 1)      this.date = new Date(this.date)    }  }})