在首页接口返回后注册的某个模块(组件),不是main.js注册的
去别的页面也用这个组件,发现也能用
Vue.component()本身就是注册全局组件用的 把组件直接挂在了vue实例身上 和你在哪写没关系
【相关推荐】
说的通俗点,就是在components
里面再写一个components
,调用里面的组件是需要注意的(可以无限嵌套)。
<father></father>
<!--父组件的模版-->
<template id="father_tpl">
<div style="width: 100px; height: 100px; background-color: skyblue;">
<!--子组件只能在父组件中使用-->
<child></child>
</div>
</template>
<script>
new Vue({
components: {
'father': {
template: '#father_tpl',
components: {
'child': {
template: '<p>我是里面的组件</p>',
}
}
}
}
}).$mount('#app');
</script>