5***@qq.com
5***@qq.com
  • 发布:2019-10-05 13:05
  • 更新:2020-03-26 15:17
  • 阅读:8447

axios 真机调试报错:TypeError: adapter is not a function,预览正常

分类:uni-app

axios预览时功能都正常,用手机真机调试时报错:TypeError: adapter is not a function,百度后没有找到解决办法

2019-10-05 13:05 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

同问

2***@qq.com

2***@qq.com

请问解决了吗 遇到了同样的问题

  • p***@163.com

    大佬,请问您解决这个问题了吗

    2020-01-08 20:59

2***@qq.com

2***@qq.com

同问,同样的问题,有人解决了吗?

p***@163.com

p***@163.com - liangxingzhi

同问,各位大佬求助

  • mdf

    然后官方管你死活,根本不鸟你

    2020-01-09 09:11

7***@qq.com

7***@qq.com - 克里斯7

用原生的axios库使用确实在app端有这样的问题, 插件市场有个大佬封装了一下axios 我直接替换过来 发现就没有这个问题了.
https://ext.dcloud.net.cn/plugin?id=558 你们可以试试.

猫猫儿

猫猫儿 - 猫猫儿

我也是,但是不知道为什么开了“调试”就不会出现

  • x***@foxmail.com

    //真机获取

    axios.defaults.adapter = function (config) {

    return new Promise((resolve, reject) => {

    var settle = require('axios/lib/core/settle');

    var buildURL = require('axios/lib/helpers/buildURL');

    uni.request({

    method: config.method.toUpperCase(),

    url: buildURL(config.url, config.params, config.paramsSerializer),

    header: config.headers,

    data: config.data,

    dataType: config.dataType,

    responseType: config.responseType,

    sslVerify: config.sslVerify,

    complete:function complete(response){

    response = {

    data: response.data,

    status: response.statusCode,

    errMsg: response.errMsg,

    header: response.header,

    config: config

    };


            settle(resolve, reject, response);    
    }
    })
    })

    }

    2020-03-28 12:36

  • 1***@qq.com

    https://ask.dcloud.net.cn/article/36728

    2020-04-15 16:08

  • aiplat点com

    回复 x***@foxmail.com: 这个 正常

    2020-08-26 20:39

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