tp6如何生成全静态页面,如何使用 buildHtml生成静态页面

浏览:2607 发布日期:2020/06/28 分类:ThinkPHP6专区
第一步在 baseController.php 中添加 public function buildHtml($htmlfile = '', $htmlpath = '', $templateFile = '')    
 {        
 $content=View::fetch($templateFile);        
 $htmlpath = !empty($htmlpath) ? $htmlpath : './appTemplate/';        
 $htmlfile = $htmlpath . $htmlfile . '.'.config('view.view_suffix');        
 $File = new \think\template\driver\File();        
 $File->write($htmlfile, $content);        
 return $content;    
 }
第二步 调用 Viewuse think\facade\View;第三步 前端使用 $this->buildHtml('index',HTTP_PATH."index/",$tempSrc);    //1.文件命名 2.保存地址 3.需要生成文件

文章转发:https://www.hbsjsd.cn/art/list/341.html
最佳答案
评论( 相关
后面还有条评论,点击查看>>