PHP Tp6模板布局
作者:互联网
在Base层:
<?php
declare (strict_types=1);
namespace app\home\controller;
use app\BaseController;
use app\brand\model\Category;
use think\App;
use think\facade\Session;
use think\Request;
use think\facade\View;
class Base extends BaseController
{
public function __construct(App $app)
{
parent::__construct($app);
header('Access-Control-Allow-Origin:*');
//允许的请求头信息
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
//允许的请求类型
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
//允许携带证书式访问(携带cookie)
header('Access-Control-Allow-Credentials:true');
$cate = Category::where([])->select();
$data= \app\home\business\Index::get_tree($cate);
return View::assign('data',$data);
}
}
标签:Control,use,header,app,Access,Tp6,Allow,PHP,模板 来源: https://www.cnblogs.com/qsn17501005/p/15748285.html