is属性
有组件 myCom1 和 myCom
<div id="app">
<input type="button" @click="changeIt">
<component :is="name"></component>
</div>
changeIt() {
this.name= this.name == 'myCom' ? 'myCom1' : 'myCom';
}
本文介绍在Vue中如何使用is属性实现动态组件切换,通过点击按钮改变当前显示的组件,涉及myCom1和myCom两个组件的动态加载和切换。
is属性
有组件 myCom1 和 myCom
<div id="app">
<input type="button" @click="changeIt">
<component :is="name"></component>
</div>
changeIt() {
this.name= this.name == 'myCom' ? 'myCom1' : 'myCom';
}

被折叠的 条评论
为什么被折叠?