一.首先有首页:index.vue
<template>
<view class="content">
<testA></testA>
<testB></testB>
</view>
</template>
<script>
// ab组件
import testA from '../../components/test/test-a.vue'
import testB from '../../components/test/test-b.vue'
export default {
components:{
testA,
testB,
},
</script>
<style>
</style>
二.test-a组件
<template>
<view>
<!-- 具体查看 框架页面页面通信 -->
这是a组件 :<button @click="addNum">修改b组件的数据{
{num}}</button>
</view>
</template>
<script>
export default{
data(){
return{
num:0,
}
},
methods:{
addNum(){
uni.$emit('updateNum',10)
}
}
}
</script>
<style>
</style>
三.test-b组件
<template>