SOURCE

console 命令行工具 X clear

                    
>
console
Vue.component('CompA', {
    template: `<div>CompA</div>`
});
Vue.component('CompB', {
    template: `<div>CompB</div>`
});
const vm = new Vue({
    el: '#app',
    data: {
        currentComp: 'CompA'
    },
    methods: {
        changeComp() {
            if (this.currentComp === 'CompA') {
                this.currentComp = 'CompB';
            } else {
                this.currentComp = 'CompA';
            }
        }
    }
});
<div id="app">
    <!-- 动态组件 -->
    <component :is="currentComp"></component>
    <button @click="changeComp">切换组件</button>
</div>

本项目引用的自定义外部资源