1.创建vue项目
vue create hello-world
2.构建单页面
npx vue-cli-service build --target lib --name myLib src/components/HelloWorld.vue
3.绑定在页面
1.用模板绑定
<div id="app">
<demo></demo>
</div>
<script>
new Vue({
components: {
demo: myLib
}
}).$mount('#app')
</script>
2.用 vue文件绑定
<div id="app">
</div>
<script>
const AA = Vue.extend(myLib);
new AA({
data () {
return {
a:'demo1'
}
}
}).$mount('#app')
</script>