微信小游戏,在IDE跟真机调试的时候,wx.request经常在第一次打开IDE,或者第一次真机调试的时候,wx.request没有返回到数据,无论是scuccess fail complete,全都没有返回。不过我抓包跟看IDE的networks,接口是有返回到东西的。然后第二次进去的时候,就有数据返回了。
而且第一次进游戏的时候还经常加载资源失败
appid:wx879b745956e34f2f
wx.request({ ...options, success: res => { starConfig.debug && console.log(new Date().getTime(), options.url, res) // 关闭 loading,如果存在 conf.showLoading && wx.hideLoading() console.log(res, '=========res'); if (res.statusCode === 200 && (res.data && (res.data.code === undefined || res.data.code === 200))) { resolve(res) } else { if (conf.showToast) { if (res.data && res.data.msg) { conf.toastParams.title = res.data.msg } wx.showToast(conf.toastParams) } reject(res) } }, fail: res => { console.log(err, '=========err'); starConfig.debug && console.log(new Date().getTime(), options.url, res) // 关闭 loading,如果存在 conf.showLoading && wx.hideLoading() if (conf.showToast) { if (res.errMsg) { conf.toastParams.title = res.errMsg } wx.showToast(conf.toastParams) } reject(res) }, complete(res) { console.log(res, '======complete'); } })
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。