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);

}
}

 

上一篇:PHP做301重定向设置的代码方法


下一篇:nginx 反向代理常用配置