vue一个页面根据不同状态展示不同组件
<component :is='currentRole' @changeRole="changeRole"></component>
import Apply from './talent/apply'
components:{
Apply,
},
data(){
return{
currentRole:''
}
},
mounted(){
this.currentRole = 'Apply'
},
methods:{
changeRole(e){
this.currentRole = e
}
}
<div @click="$emit('changeRole','Apply')">切换组件</div>
子组件通过$emit('changeRole','传值')调用更换状态