vue 动态组件
常用于在不同组件间进行动态切换。主要通过<component>
的is特性来实现。
示例代码:
<template>
<component :is='currentView' @changeView='changeCurrentView'>
</template>
script>
import topBack from '../components/topBack'
import home from '../components/home'
import result from '../components/result '
export default {
components: {topBack,home,result},
data() {
return {
currentView:'home'
}
},
methods: {
changeCurrentView(val){
this.currentView=val
},
}
</script>