完整教程:uniapp中使用aixos 报错

问题:

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

使用如下:

import axios from 'axios'
import axiosAdapterUniapp from 'axios-adapter-uniapp'
const instance = axios.create({
  baseURL: 'URL.com',
  adapter: axiosAdapterUniapp
})
posted @ 2025-07-23 08:25  yfceshi  阅读(58)  评论(0)    收藏  举报