Yii的各种render
生活随笔
收集整理的這篇文章主要介紹了
Yii的各种render
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
各種render
① render使用view和layout渲染
② renderPartial只渲染view? ? 不渲染布局? ?就是分配數據? 不使用布局
return $this->renderPartial("@app/views/common/js.php",['msg' => $msg,'url' => $url]);③ renderContent只渲染layout? ?不會作用view
renders a static string by embedding it into the currently applicable layout. This method is available since version 2.0.1.通過將靜態字符串嵌入到當前適用的布局中來呈現它。此方法在2.0.1版之后可用。④ renderFile顯示指定的文件,是最基礎的方法, renderAjax,renderPartial最終都是調用renderFile.
<?=Yii::$app->view->renderFile("@app/modules/web/views/common/tab_user.php",['current' => 'edit']);?> 此處的Yii::$app->view相當于$this(這個是yii內置的 還有$model也是內置的)⑤ renderAjax只顯示view不用布局,以ajax方式渲染頁面,可以配合js/css實現各種特效
?
視圖組件
直接使用render是簡寫發 ;
renderFile是完整的寫法;
<?= $this->render('_overview') ?> echo \Yii::$app->view->renderFile('@app/views/site/license.php');總結
以上是生活随笔為你收集整理的Yii的各种render的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP的strlen与mb_strlen
- 下一篇: Basic英文单词