以当前模块下的view为起始点访问模板文件
{include file=“public/header” /}
这截图应该是模板布局的截图 当做参考吧
模板继承展示页面 test2.html 引用模板继承方式
<!--继承基础模板-->
{extend name="public/base" /}
<!--区块部分-->
{block name="body"}
<h2>我是模板继承的案例</h2>
{/block}
基础模板 base.html
{include file="public/header" /}
{block name="body"}
主体替换部分
{/block}
{include file="public/footer" /}
公共页 head.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h2 style="color:red">我是网站的头部</h2>
控制器
<?php
namespace app\index\controller;
use think\Controller;
class Demo8 extends Controller
{
public function test2()
{
return $this->view->fetch();
}
}