在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)
}