doubleyong
管理员
管理员
  • 最后登录2025-02-06
  • 发帖数1196
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:444回复:0

[其它]uniapp 使用 axios 报错errAxiosError: There is no suitable adapter to dispatch the request since

楼主#
更多 发布于:2024-11-22 12:02
问题:

在uniapp中使用aixos,运行后报如下错误:
AxiosError: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build


解决方案:
配置axios适配器(axios-adapter-uniapp)
Using npm:
npm install axios-adapter-uniapp


Using yarn:
yarn add axios-adapter-uniapp


使用如下:

mport axios from 'axios'
import axiosAdapterUniapp from 'axios-adapter-uniapp'
 
const instance = axios.create({
  baseURL: 'URL.com',
  adapter: axiosAdapterUniapp
})


在Axios引用了adapter后,使用正常。
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号