abstract://控制器<?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() {
//控制器
<?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { //渲染视图 return $this->fetch(); } public function add(){ //渲染视图 return $this->fetch(); } }
//模板部分
index.hml
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题</title> <style type="text/css"> .main{ width: 800px; height: 600px; background: black; margin: auto; text-align: center; line-height: 600px; color: red; } </style> </head> <body> <div class="main">这个是index.html</div> </body> </html>
//add.html
{extend name="common"/} {//重新父模板} {block name="common"} <div style="text-align: center;"> 主体部分</div> {/block}
//common.html
{//头部内容} {block name="header"} {include file="public/header"} {/block} {block name="main"} 主体部分{/block} {block name="footer"} {include file="public/footer"} {/block}
//layout.html
{include file="public/header"} {__CONTENT__} {include file="public/footer"}
Correcting teacher:查无此人Correction time:2019-02-18 09:33:45
Teacher's summary:看的不是太明白。header,footer这两个文件没有列出来?怕你把html,head标签重复了。继续加油。