1.首先在页面上正常引入vue.js文件(可引入离线包,也可引入官网上的cdn链接)
我是引入的离线包:
2.通过引入httpVueLoader文件,来加载一个新的vue子组件
先引入进来:
httpVueLoader下载方式:https://download.csdn.net/download/qq_38804584/16524043?spm=1001.2014.3001.5503
3.使用方法:
先创建一个新的vue组件:
画重点,特别注意:子组件中script中用module.exports = {}的形式,不然肯定不行
这是重点注意地方 !!!!
3.最后vue中使用方法:
方法1:
<body>
<div id="test">
<hello title="哈哈"></hello>
</div>
</body>
<script>
Vue.use(httpVueLoader);
new Vue({
el:'#test',
data(){
return{
}
},
methods:{
},
components:{
'hello': 'url:../components/hello.vue',
}
})
</script>
方法2:
<body>
<div id="test">
<hello title="哈哈"></hello>
</div>
</body>
<script>
Vue.use(httpVueLoader);
new Vue({
el:'#test',
data(){
return{
}
},
methods:{
},
components:{
'hello':httpVueLoader('../components/hello.vue')
}
})
</script>
声明:这是我同事弄出来的哈,她查询了很多资料,找到了httpVueLoader文件,引进去发现各种报错,跨域什么的,然后她就自己修改了这个文件,我们两个加以测试,可以正常使用!