子组件
<template>
<view class="">
测试
{{title}}
<view @click="sendNum">
1111
</view>
</view>
</template>
<script>
export default {
data() {
return {
num:12
}
},
props:['title'],
methods: {
sendNum(){
this.$emit('sendNum',this.num)
}
},
}
</script>
<style>
</style>
父亲
<template>
<view class="container">
<Test :title="title" @sendNum="getNum"></Test>
<text>{{num}}</text>
</view>
</template>
<style lang="scss" scoped>
</style>
<script>
import Test from '../../components/Test/Test.vue';
export default {
components:{
Test
},
data() {
return {
title:'hello',
num:''
}
},
methods: {
getNum(num){
this.num=num
}
},
}
</script>