在入口文件加入代码
/*星号表示所有的域都可以接受,*/
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:GET,POST,PUT,OPTIONS");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); //支持的http 动作
header('Access-Control-Allow-Headers:x-requested-with,content-type,Authorization');