problem description
here are the global parameters in the info.js call app.js
app.jsrole
info successfully prints out role=null; after loading for the first time. Then I call a method app.js in info.js and change the parameter of role value in app.js = "EMP";
I think the role=null; defined by data in info.js is also =" EMP";
the environmental background of the problems and what methods you have tried
I can"t figure out how to do it,
related codes
/ / Please paste the code text below (do not replace the code with pictures)
info.js code
const app = getApp()
Page({
data: {
role:undefined,
},
onLoad: function() {
let that = this;
that.setData({
role:app.globalData.role
})
},
onReady: function () {
console.log(this.data.role)//role=null
app.getRole()
console.log(this.data.role)//role=null,role="EMP"
},
})
app.js
App({
globalData: { //
role:"null",
},
getRole:function(){
let that = this;
that.globalData.role = "EMP";
console.log(that.globalData.role)//="EMP"
}
})
what result do you expect? What is the error message actually seen?
some people say that they use Promise, but they don"t know how to write it, and whether they can list it.