web前端|uni|app

uni.$on('函數(shù)名',(形參數(shù))=>{...});
2、在傳遞參數(shù)的組件中注冊(cè)全局函數(shù)
uni.$emit('函數(shù)名',參數(shù))
代碼示例:
接收參數(shù):
meme {{this.num}}export default{data(){return{num:12}},created(){uni.$on('update',(num)=>{this.num=num;});}}
傳遞參數(shù):
import det from '../detail/detail.vue'import me from '../me/me.vue'export default{data(){return{imgArr:['a'],num2:11}},components:{det,me},methods:{get(){uni.$emit('update',this.num2);}}}@import url("../css/a.css");.box{height: 375rpx;width: 375rpx;/* #ifdef H5 */background-color: #4CD964;/* #endif *//* #ifdef APP-PLUS */background-color: #007AFF;/* #endif */}.box1{background-color: #007AFF;}
聲明:所有內(nèi)容來(lái)自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。