前端请求接口出现的跨域问题

1.针对跨域问题可以使用jsonp的方式解决

2.可以使用header头来定义

header('Access-Control-Allow-origin:*');
header('Access-Control-Allow-Credentials:true');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers:Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With');
header('Content-Type: text/html; charset=utf-8');

加上以后就可以了

但是这个缺陷是IE10以下的不支持!一般手机应用都可以用!

原文地址:https://www.cnblogs.com/findher/p/10610601.html