hideLoading:fail:toast can't be found
发布于 3 年前 作者 cliao 5057 次浏览 来自 分享

真的是头大,出现了很多次报错,刚开始,没一点头绪。后来算是解决了。

下面是我封装的函数,之前,写的一直是wx.hideLoading(),不知打印的报错原因出在哪,后来把里面的fail和success和complete补全了,发现不报错了。

let postajaxtimes = 0
export const sendGetReuest = (params) => {
  postajaxtimes++
  return new Promise(function (resolve, reject{
    wx.showLoading({
      title'加载中',
      masktrue
    })
    wx.request({
      // url: url,
      ...params,
      method"Get",
      success(res) {
        resolve(res)
      },
      fail(err) {
        reject(err)
      },
      complete() => {
        postajaxtimes--
        if (postajaxtimes === 0) {
          // 关闭正在等待的图标
          // wx.hideLoading()
          wx.hideLoading({
            fail:()=>{},
            success:()=>{},
            complete(complete) => {}
          })
        }
      }
    })
  })
}
回到顶部