uniApp 监听globalData
作者:互联网
App.vue
globalData:{ infoType:'' }, methods:{ watch:function(method,istr){ var obj=this.globalData console.log(obj) Object.defineProperty(obj,istr,{ configurable:true, enumerable:true, set:function(value){ this._consumerGoodsStatus=value method(value) }, get:function(value){ return this._consumerGoodsStatus } }) } },
页面调用
getApp().watch(this.getcartcount,'infoType')
getcartcount(val){ console.log('输出变化的值',val) },
标签:function,uniApp,obj,value,globalData,infoType,getcartcount,监听 来源: https://www.cnblogs.com/wangshishuai/p/15954439.html