PHP教程

PHP Tp6模板布局

本文主要是介绍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 Tp6模板布局的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!