VUE使用component :is 實現在多個組件間來回切換
component :is 動態父子組件傳值
相關代碼實現:
<component:is="vuecomponent"></component>import componentA from 'xxx';
import componentB from 'xxx';
import componentC from 'xxx';switch(item) {case A:this.vuecomponent = 'componentA';break;case B:this.vuecomponent = 'componentB';break;
default:this.vuecomponent = 'componentC';
}
vue官方文檔解釋:
參考文檔:組件基礎 | Vue.js (vuejs.org)