problem description
defines the global variable userNum:null, in app.js by modifying the value of the global variable userNum in login.js, and then getting userNum, in another page, but its value is still null. Var app = getApp ();
is written on the page. It is said on the Internet that the value can be obtained, but it has not been obtained.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
app.js
globalData: {
userInfo: null,
userNum:null
}
login.js
app.globalData.userNum = username; //
console.log(app.globalData.userNum); //
another page:
wx.request({
url: "...", //()
method: "GET",
header: {
"content-type": "application/json"
},
data: {
stunum: app.globalData.userNum //stunumnull
},
success: function(res) {
console.log(res.data);
}
})