子组件
props: {
props:['childdata'], // 定义在父组件中的变量
},
methods: {
this.$emit("getchilddata", data) // getchilddata 父组件中使用的指令名
}
父组件
在父组件中引入子组件
<childbody @getchilddata="getchilddata" ></childbody>
data() {
return {
childdata:"",
}
methods:{
getchilddata(data){ // 接受从自组件传过来的值
console.log('从子组件传过来的值' + data )
},
}
Vue组件间通信
1047

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



