收藏
回答

RequestTask.onHeadersReceived同时只有一个回调?

onLoad() {
    this.a1()
    this.a2()
    this.a3()
  },
  a1:function(){
    console.log('a1_________start')
    let requestTask = wx.request({
      url: "https://cdn-h.gongfudou.com/tmp/2024/10/17/a069c56c-1c2a-410a-8a4d-810732906f57.pdf",
      data: {},
      method:'HEAD',
      header: {
        'Content-Type':'application/x-www-form-urlencoded',
      }
    })
    requestTask.onHeadersReceived((res) => {
      console.log("a1_________end")
    })
  },
  a2:function(){
    console.log('a2_________start')
    let requestTask = wx.request({
      url: "https://cdn-h.gongfudou.com/tmp/2024/10/17/a069c56c-1c2a-410a-8a4d-810732906f57.pdf",
      data: {},
      method:'HEAD',
      header: {
        'Content-Type':'application/x-www-form-urlencoded',
      }
    })
    requestTask.onHeadersReceived((res) => {
      console.log("a2_________end")
    })
  },
  a3:function(){
    console.log('a3_________start')
    let requestTask = wx.request({
      url: "https://cdn-h.gongfudou.com/tmp/2024/10/17/a069c56c-1c2a-410a-8a4d-810732906f57.pdf",
      data: {},
      method:'HEAD',
      header: {
        'Content-Type':'application/x-www-form-urlencoded',
      }
    })
    requestTask.onHeadersReceived((res) => {
      console.log("a3_________end")
    })
  },

理论上是有三个start和三个end输出一共六条输出

在按说和模拟器上都是正常输出

但是在IOS上只有一个end输出

以前是正常的昨天有客户反馈异常排查下来是这个问题

在IOS上多个request的onHeadersReceived监听同时执行时只有一个onHeadersReceived的回调会有反馈


回答关注问题邀请回答
收藏
登录 后发表内容