作者 lihan
1 个管道 的构建 通过 耗费 1 秒

跨域问题

... ... @@ -13,6 +13,19 @@ use think\Db;
class PlaceController extends HomeBaseController
{
function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求
// 指定允许其他域名访问
header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:POST');
// 响应头设置
header('Access-Control-Allow-Headers:x-requested-with,content-type');
}
public function add()
{
$request = request();
... ...