vuejs component created wait for data to load first

This is not the Vue way of doing things.

  1. Use VUEX to store your currentUser object
  2. Set up the Vuex getters in App.vue's computed section. Your template will be updated dynamically once the data is ready.

See the mapGetters section in this page. It works very well with the computed mechanism.

You can also use v-if in your relevant component, so that the component won't be created before your data is ready in VUEX.


I ran into a very similar problem and solved by adding a v-if on the element that wrapped the child component that depends on the loaded data. And then of course have an data property to control that v-if. If you don't have a wrapping element you can always use a template element to do the wrapping.