uniapp 子组件给子组件传值
作者:互联网
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','桂明明') } } }
标签:uniapp,wife,num,export,组件,uni,emit,传值 来源: https://www.cnblogs.com/xm666/p/15496921.html