比如有组件 C 和 D ,他们根据传入的数据不同,界面也不一样。 现在组件 B 里 import 组件 C 和 D ,请问如何在 js 代码里给 C , D 组件传递数据呢?
<template>
<div>
<component :is="currentView"></component>
</div>
</template>
<script>
import C from './C.vue'
import D from './D.vue'
export default {
data() {
return {
currentView:null
}
},
methods: {
clickSwitch(row, event){
if(row.type==='c'){
this.currentView = C; //这里如果给 C 组件传送数据呢?
}else{
this.currentView = D;//这里如果给 D 组件传送数据呢?
}
}
}
}
</script>