我的知识记录分享

我的知识记录分享

uniapp跨域处理

2021-1-11 糖果小宝 html

配置文件添加
 "h5" : {
        "devServer" : {
            "https" : false,
			"proxy": {
			           "/api": {
			                "target": "http://api.******.com/",
			                "changeOrigin": true,
			                "pathRewrite": {
			                    "^/api": ""
			                }
			            }
			        }
        }
    }

如果还有问题
关键添加这段
"content-type":"application/x-www-form-urlencoded;application/json;charset=UTF-8"

拦截器添加 指定类型
Vue.prototype.$u.http.setConfig({
		//baseUrl: 'http://api.*****.com',
		loadingText: '努力加载中~',
		loadingTime: 800,  
		header:{
			"content-type":"application/x-www-form-urlencoded;application/json;charset=UTF-8"
		}
	});




发表评论: