Vue中各属性执行顺序

249 阅读1分钟
// main.js
store.dispatch('getUserInfo').then(() => {
      // 创建了APP应用,然后挂载到id=app的元素上,并使用了store和router。
     // store,router 成了全局的啦,this.$store.xxx;this.$router.xxx
      instance = new Vue({
          el: '#app',
          router,
          store,
          template: '<App/>',
          components: { App }
      });
  }).catch(utils.handlePromiseRejection);
  • index.html -->main.js;
  • main.js 挂载了app.vue; app.vue 的template 替换index,html 中的 <div id="app">;
  • app.vue 的template 包含
    (1)dom啥的
    (2)router 对应的组件渲染到router-view中

image.png