vue 子组件调用父组件方法

时间:2023-01-30 21:12:25

父组件vue

<privateScoreTop :msg ="Widget" v-on:listenTochildEvent="showMessageFromChild">
</privateScoreTop>

父组件js

export default{
data(){
return {
}
},
computed:{
privateScoreTop : ()=>import("./privateScoreTop.vue")
},
mounted(){
},
methods:{
showMessageFromChild(data){
console.log("回掉子组件成功"+data);
}
}
}

子组件js

export default{
methods: {
onfilter(){
this.$emit("listenTochildEvent",{回传参数})
;
}
,
}
}