<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ### 組件說明 > View組件用于渲染視圖模板。 ### 配置選項 | 配置名 | 參數類型 | 可選 | 默認值 | 說明 | | --- | --- | --- | --- | --- | | class | string | 是 | lying\view\View | 不可更改 | | suffix | string | 是 | html | 模板文件的后綴名,如果此項設置為php,表示用php模板,否則用內置模板引擎 | | cache | string | 是 | template | 模板緩存組件ID | ### 示例配置 ~~~php //緩存組件(用于模板緩存) 'tplCache' => [ 'class' => 'lying\cache\FileCache', //必須是文件緩存 'dir' => DIR_RUNTIME . DS . 'compile', 'gc' => 80, 'suffix' => 'php', 'serialize' => false, ], //視圖設置 'view' => [ 'class' => 'lying\db\Cookie', //view為核心組件,所以此項可不寫 'suffix' => 'html', 'cache' => 'tplCache', //此參數一般情況下不比配置,使用默認的即可 ], ~~~ ### 調用方式 ~~~php \Lying::$maker->get('view'); \Lying::$maker->view(); \Lying::$maker->view; ~~~ ### 方法列表 ~~~php /** * 渲染模板 * @param string $view 模板 * @param array $params 模板參數 * @param Controller $context 上下文 * @return string 返回渲染后的模板 */ public function render($view, $params, Controller $context = null); ~~~ * * * * * ~~~php /** * 渲染模板文件 * @param string $file 模板文件絕對路徑 * @param array $params 模板參數 * @param Controller $context 上下文 * @return string 返回渲染后的模板 */ public function renderFile($file, $params, Controller $context = null); ~~~ ***** ~~~php /** * 渲染php模板 * @param string $file 模板文件 * @param array $params 模板參數 * @return string 返回渲染結果 * @throws \Throwable|\Exception */ public function renderPhp($file, $params); ~~~ ***** ~~~ /** * 解析視圖路徑 * @param string $view 解析的視圖 * @param Controller $context 上下文 * @return string 返回視圖文件的絕對路徑 * @throws \Exception 文件不存在拋出異常 */ public function resovePath($view, Controller $context = null); ~~~ ### 使用示例 ~~~php <?php namespace module\index\controller; use lying\service\Controller; /** * Class IndexCtrl * @package module\index\controller */ class IndexCtrl extends Controller { /** * 首頁 * @return string */ public function index() { //更多的輸出方式 $view = $this->maker->view; //輸出渲染后的頁面 //return $view->render('/www/project/tpl.html', ['name'=>'lying']); //return $view->render('index', ['name'=>'lying'], $this); //帶有context //return $view->renderFile('/www/project/tpl.html', ['name'=>'lying']); //根據context返回視圖文件的絕對路徑,如果沒有context,則返回帶后綴的文件名 echo $view->resovePath('abc', $this); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看