收藏
回答

为什么我的wx.request没有返回数据

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小游戏 Bug wx.request 微信iOS客户端 不确定 2.14.3

微信小游戏,在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');         }       })
最后一次编辑于  2021-01-25
回答关注问题邀请回答
收藏

1 个回答

  • 小游戏运营专员 - 宏
    小游戏运营专员 - 宏
    2021-01-27

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2021-01-27
    有用
    回复
登录 后发表内容
问题标签