Vue启动分析

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huning188/article/details/84073060

新建项目

npm init webpack vue-learn

main.js

new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
})

此处加入template属性后,vue启动会用App组件的内容换掉挂载点元素;

index.html

  <body>
    <div id="app"></div>
  </body>

如果没有template属性,需要在index.html中挂载点中写入组件app。

main.js

new Vue({
  el: '#app',
  components: { App }
})

index.html

  <body>
    <div id="app">
        <app></app>
    </div>
  </body>

参考资料:

https://segmentfault.com/q/1010000012470922

猜你喜欢

转载自blog.csdn.net/huning188/article/details/84073060
今日推荐