在类里添加这几句即可
header('Access-Control-Allow-Origin:*');
// // 响应类型
header('Access-Control-Allow-Methods:*');
// 响应头设置
header('Access-Control-Allow-Headers:x-requested-with,content-type');
来源:oschina
链接:https://my.oschina.net/u/3371661/blog/3476135