[Vuejs]-Vue.js – this.<value>.<value> is undefined

0👍

computed properties are calculated right away: they are calculated before your Ajax returns.

Since you only populate persondata when the Ajax returns, the first time the computed is calculated, persondata is {} (the value of initialization in data).

Quick fix: initialize with an empty dates object, so the computation doesn’t throw that error (giving time for the Ajax to return, which will update the computed property automatically):

  data () {
    return {
      persondata: {dates: {}}, // added empty dates property
    }
  },

Leave a comment