[Vuejs]-Vue data not loading for Liquor treeData

0👍

Use a lifecycle hook (such as created) to asynchronously load async data:

new Vue({
   ...
   data: () => ({
      treeData: null,    // Starts empty
   }),
   async created() {     // async load
     const response = await axios.get(...);
     this.treeData = response.data;
   }
   ...
})

Use a v-if in the template so that <tree> doesn’t render before the data is ready:

<tree 
   v-if="treeData"
   :data="treeData"
   :options="treeOptions"
/>

(Remove init and the DOM onload)

Leave a comment