版权声明:本文为博主原创文章,未经博主允许不得转载。 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>