关于无法在uniapp项目开发中使用axios的解决方案

问题描述

首先需要指出的是uniapp官方提供了uni.request方法来进行网络请求访问(还是建议使用这个),不过如果像往常项目编写中继续使用axios的话就会出现以下错误:

{ "message": "There is no suitable adapter to dispatch the request since :\n- adapter xhr is not supported by the environment\n- adapter http is not available in the build", "name": "AxiosError", "stack": "AxiosError: There is no suitable adapter to dispatch the request since :\n- adapter xhr is not supported by the environment\n- adapter http is not available in the build\n at Object.getAdapter (app-service.js:1674:15)\n at Axios.dispatchRequest (app-service.js:1701:30)\n at Axios._request (app-service.js:1978:35)\n at Axios.request (app-service.js:1882:27)\n at Axios. [as get] (app-service.js:1997:19)\n at Function.wrap [as get] (app-service.js:192:17)\n at getPic (app-service.js:2454:23)\n at app-service.js:2464:9

你可能感兴趣的:(uni-app,前端,vue)