摘要:{include file="public/header" /}
{__CONTENT__}
{include file="public/footer"}
.header{
width:800px;
height: 60p{include file="public/header" /}
{__CONTENT__}
{include file="public/footer"}
.header{
width:800px;
height: 60px;
line-height: 60px;
text-align: center;
background: wheat;
margin:auto;
}
namespace app\index\controller;
use think\Controller;
class ViewTest extends Controller
{
public function index()
{
/*
第一种方式:全局配置,修改配置文件template.php
//开启布局
'layout_on' => true,
//布局文件名
'layout_name' => 'layout'
第二种方式 模板标签
{layout name="layout" /}
第三种方式 动态配置
*/
// $this->view->engine->layout(true);
// return $this->view->fetch();
return $this->view->engine->layout(true)->fetch('view_test\index');
}
}
批改老师:天蓬老师批改时间:2019-01-30 09:21:38
老师总结:布局是一种比较高级和抽象的技术, 可能在实际工作中, 还不如文件包含来得痛快, 其实, 所有布局模式,都可以通过文件包含来解决, 或者是文件包含一种快捷方式罢了, 这个一定要明白,不可以滥用