[Vuejs]-Why is my computed property for a date not reactive on changes?

0👍

Updating the value of the existing Date object doesn’t work, as Vue isn’t aware of the change. You need to set dateTime to a new Date object in order to trigger an update:

set(val) {
  this.dateTime = new Date(
    this.dateTime.setFullYear(
      val.substr(0, 4),
      Number(val.substr(5, 2) - 1),
      val.substr(8, 2)
    )
  );
}

Leave a comment