目前碰到个问题: 我在 app.js 中有 3 个网络请求, 在程序启动的时候 index 就是直接 load 起来了, 没有等待 request 完成。
目前使用了 callback 在 index 但是 callback 还是 没有来的及执行, 有什么比较好的解决方案吗
// app.js
promisify(wx.checkSession).then(() => {
return my_getUserInfo(token)
}).then(resp => {
if (that.userInfoReadyCallback) {
that.userInfoReadyCallback(resp)
}
console.log("用户信息--get token", this.globalData.userInfo)
}).catch(err => {
console.log("登录失败", err)
});
// index.js
app.userInfoReadyCallback = resp => {
console.log("call back 获取用户信息");
redirect2_home(app)
}