marsyu
marsyu
  • 发布:2019-10-31 09:25
  • 更新:2020-03-06 18:56
  • 阅读:1956

uniapp打包ios以及低版本开发者工具关于promise报错 .finally is not a function

分类:uni-app

目前使用cli配合vscode打包,项目转移自mp-vue。打包以后发现ios真机调试以及低版本开发者工具调试 v1.02.1904090会报 Promise的finally方法错误。使用新版本开发工具以及安卓均无此错误。以下为报错位置调用的通用方法。


request ({isToken = true, url = '', method = 'GET', data = {}, suc = () => {}, fail = () => {}, complete = () => {}, config = {}}) {  
      if (!url) {  
        wx.showToast({  
          title: '请求地址不正确',  
          icon: 'none'  
        })  
        return false  
      }  
      let header = {  
        'content-type': 'application/json'  
      }  
      console.log(url,'url1')  
      config.header && Object.assign(header, config.header)  
      let params = {}  
      if (isToken) params.token = this.login.token  
      Object.assign(params, data)  
      return this.getSign().then((obj) => {  
        params.sign = obj.sign  
        return new Promise((resolve, reject) => {  
          let _request = ()=>{  
            wx.request({  
              url: url,  
              data: params,  
              method: method,  
              header: header,  
              dataType: config.dataType || 'json',  
              responseType: config.responseType || 'text',  
              success: (res) => {  
                if ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304) {  
                  resolve(res.data)  
                } else {  
                  wx.showToast({  
                    title: `网络错误:${res.statusCode}`,  
                    icon: none  
                  })  
                  reject({  
                    msg: `网络错误:${res.statusCode}`,  
                    detail: res  
                  })  
                }  
              },  
              fail: (err) => {  
                wx.showToast({  
                  title: '请求失败',  
                  icon: 'none'  
                })  
                reject({  
                  msg: '请求失败',  
                  detail: err  
                })  
              }  
            })  
          }  
          if(new Date() - global.requestTime > 50){  
            _request()  
          }else{  
            setTimeout(() => {  
              _request()  
            }, 80);  
          }  
          global.requestTime = new Date()  
        })  
      }).then((res) => {  
        if (res.success) {  
          res.data ? suc(res.data,res.loginStatus||undefined) : suc(undefined)  
        } else {  
          fail(res)  
        }  
        complete()  
      }).catch((err) => {  
        console.error(err)  
        wx.hideLoading()  
      }).finally(() => {  
        console.log(url,'url')  
        complete()  
      })  
2019-10-31 09:25 负责人:无 分享
已邀请:
s***@outlook.com

s***@outlook.com

请问这个问题解决了吗?

d***@qq.com

d***@qq.com

好像是不支持, 我也遇到了

该问题目前已经被锁定, 无法添加新回复