vue设置
Vue.config.productionTip = false
Vue.prototype.$http.config.headers={
'content-type': 'application/x-www-form-urlencoded'
// 'token':uni.getStorageSync('uuid')
}
Vue.prototype.$http.config.baseURL='XXX';
服务器 ng配置文件
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
add_header Access-Control-Allow-Origin *;
代码设置
header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:*');
// 响应头设置
header('Access-Control-Allow-Headers:*');
if( $_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
exit;
}