1.官方推荐cors和插件安装解决跨域
2.配置uni-app 中 manifest.json->h5->devServer manifest.json
"h5": {
"devServer": {
"port": 8000,
"disableHostCheck": true,
"proxy": {
"/dpc": {
"target": "http://dpc.dapeis.net",
"changeOrigin": true,
"secure": false
}
}
}
}
http请求
uni.request({
url: '/dpc/getUserInfo',
success: (res) => {
console.log(res.data);
}});
本文详细介绍了如何在uni-app项目中解决跨域问题,通过配置manifest.json文件中的devServer属性来实现HTTP请求的代理转发,避免了跨域限制。同时,提供了具体的代码示例,包括配置项和请求代码。
8293

被折叠的 条评论
为什么被折叠?



