wx.request 放在onload这些没有执行,放在事件处理方法中又可以执行 ?

小程序 文章 2020-09-08 12:01 578 0 全屏看文

AI助手支持GPT4.0

wx.request 放在onload这些没有执行,放在事件处理方法中又可以执行 ?Wx.request is not executed in onload, but can it be executed in the event processing method?

wx.request 放在onload这些没有执行,放在事件处理方法中又可以执行 ?

wx.request({

  url: 'https://xxx.com/index/getUserList',

  data:{type:'11'},

  dataType:'json',

  method:'POST',

  success:function(res)

  {

    console.log(res.data)

  },fail:function(err)

  {

    console.log(err)

  },complete:function(res)

  {

    console.log(res)

  }

})

控制台中不管成功与否都没有打印的内容,这是什么意思 工具版本是 1.03.2008270

wx.request ({ url: ' https://xxx.com/index/getUserList ', data:{type:'11'}, dataType:'json', method:'POST', success:function (res) { console.log ( res.data ) }, fail:function (err) { console.log (err) }, complete:function (res) { console.log (RES)}}) the console has nothing to print whether it succeeds or not. What does this mean? The tool version is 1.03.2008270

回答:

        :为啥你这里可以我就不行 ......
stop eating:

        :为啥我的不行
stop eating:不是走success,就是走fail,都打印一下
        :success fail complete 都打印了 没有  network也没有请求信息
stop eating:换稳定版吧,别折腾了
微喵网络:你给我的代码片段里不是放在index的啊
        :是啊 在home里面,我现在又换到index下面了 还是没用....
微喵网络:放index没问题
        :不懂为啥我的就是这样子...
微喵网络:

弄一个 [ 能复现问题的简单的 ] 代码片段

https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

微喵网络:已复现,但是问题不是在onload里没执行,是跳转后没执行onload
微喵网络:为什么要在第一页的onload里就直接跳转?逻辑是什么?如果直接就跳转了,为什么不把home的内容直接放到index?
        :跳转后没执行onload 啥意思 不是很懂

-EOF-

AI助手支持GPT4.0