问题描述
官方文档写的动态组件,就一个component :is 特性就完了。。。
然后打开源码,组件写的都是模板template:"<div>.....</div>"。
我把一个完整的组件替代这个template模板,然后vue就警告报错了,找不到template或者render,这叫什么动态组件???完全鸡肋,无解。。。
相关代码
<template>
<div>
<component :is="show"></component>
</div>
</template>
<script>
import a from '@/views/system/a'
import b from '@/views/system/b'
export default {
components: {
aaa:{ a },
bbb:{ b }
},
data(){
show: aaa
}
}
......
</script>
这个代码与官方的核心区别在于
aaa:{ template:'<div>......</div>' },
bbb:{ template:'<div>......</div>'}