level 1
没人来我自己发吧…有点**,怪不得没人回。
controller下加上tp5的fetch
protected function fetchh($template = '', $vars = []){
return $this->view->fetch($template, $vars);
}
然后页面调用就行
public function startBuild($htmlfile = 'index',$htmlpath = './html/',$templet = 'index@index/index',$action = 'index/index/index'){ //index@index/index
action($action);
$info = $this->buildHtml($htmlfile,$htmlpath,$templet);
echo $info;
}
public function buildHtml($htmlfile='index',$htmlpath='./html/',$templateFile = 'index@index/index') {
$content = $this->fetchh($templateFile);
$htmlfile = $htmlpath.$htmlfile.'.html';
$File = new \think\template\driver\File();
$File->write($htmlfile,$content);
return $content;
}
2021年05月31日 10点05分
5