abstrakt://控制器<?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>無標(biāo)題</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">這個(gè)是index.html</div> </body> </html>
//add.html
{extend name="common"/} {//重新父模板} {block name="common"} <div style="text-align: center;"> 主體部分</div> {/block}
//common.html
{//頭部?jī)?nèi)容} {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"}
Korrigierender Lehrer:查無此人Korrekturzeit:2019-02-18 09:33:45
Zusammenfassung des Lehrers:看的不是太明白。header,footer這兩個(gè)文件沒有列出來?怕你把html,head標(biāo)簽重復(fù)了。繼續(xù)加油。