b组件
<view class="">{{wife}}</view>
export default { name:"b", data() { return { num:0, wife:'小红' }; }, created() { uni.$on('upnum',(num)=>{//注册全局事件 this.num +=num }), uni.$on('wi',(wife)=>{//注册全局事件 this.wife =wife }) } }
a组件:
<button type="default" @click="addNum">a让b++</button>
<button type="default" @click="changewi">改变b的wife</button>
export default { name:"a", data() { return { wife:'桂明明' }; }, methods:{ addNum(){ uni.$emit('upnum',10) //$emit()调用就好了 }, changewi(){ uni.$emit('wi','桂明明') } } }