解决uni-app中的本地跨域
关于在HbuilderX中的uni-app的本地跨域的代理解决方式:
此方式是在vue3中语法生效,如下:
创建vite.config.js,并在js中输入一下内容:
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
export default defineConfig({
plugins:[uni()],
server:{
hmr:true,
proxy:{
'/api':{
target:'https://60.214.234.34:8006/sdt/',
changeOrigin:true,
rewrite:path=>path.replace(/^\/api/,''),
secure:false
}
}
}
})
然后再baseUrl.js中的请求地址改成/api即可。

浙公网安备 33010602011771号