<template>
<h3>CompA</h3>
<component-b :onfun="dateFun"></component-b>
<p>{{msg}}</p>
</template>
<script>
import ComponentB from "@/components/ComponentB.vue";
export default {
name: "ComponentA",
components: {ComponentB},
data(){
return{
msg:"a"
}
},
methods:{
dateFun(data){
console.log(data)
this.msg=data
}
}
}
</script>
<style scoped>
</style>
<template>
<p>{{onfun('传递数据')}}</p>>
</template>
<script>
export default {
name: "ComponentB",
props:{
onfun:Function
}
}
</script>
<style scoped>
</style>
标签:vue,test4,ComponentB,-------,export,msg,data
From: https://www.cnblogs.com/lin513/p/17818508.html