[Vuejs]-How to call a method after Vuex data is available?

0👍

It turns out the “undefined” error was caused by another object that shared a key name with my stored object. Unfortunately, the nebulous error message sent me on a wild goose chase after I assumed the stored object was the issue based on my inexperience with Vuex.

1👍

Make sure the data in my_data is updating correctly in store. If still have issue, then use deep to watch my_data

watch:{
  my_data:{
    handler:function(){
      this.userData();
    },
    deep:true
  }
}

If you’re using watch to trigger method, don’t need to use to call it from the mounted.

👤Rijosh

Leave a comment