uni-app 中添加代理

236 阅读1分钟

用vue的方法填加

根目录下新建vue.config.js

module.exports = {
	devServer: {
		proxy: {
			'/': { //请求称号
				target: '', //请求的接口
				changeOrigin: true, //允许跨域
				ws: false,
				pathRewrite: {
					'^/api': '/'
				}
			}
		}
	}
}

在自己的接口api中输入http://localhost:8080 即可