Yii2 選擇布局的方式

2021-09-07 07:09:37 字數 535 閱讀 1647

方案1:控制器內成員變數

public $layout = false; //不使用布局

public $layout = "main"; //設定使用的布局檔案

方案2:控制器成員方法內

$this->layout = false; //不使用布局

$this->layout = "main"; //設定使用的布局檔案

方案3:檢視中選擇布局

$this->context->layout = false; //不使用布局 $this->context->layout = 'main'; //設定使用的布局檔案 

問題:

解決方案一,在controller中設定:

解決方案二:views中設定

。。。。。。

yii2布局選擇與屬性標籤設定

yii選擇布局的方法 1.通過控制器成員變數設定 public layout false 不使用布局 public layout main 設定使用的布局檔案 2.通過控制器方法設定 this layout false this layout main 3.在視 件中設定 this context ...

yii2框架 yii2自身的自動載入 三

上一節說完了composer的自動載入,下面我們來說一下yii2自身的自動載入。在我們的入口檔案,例如index.php,如下 comment out the following two lines when deployed to production defined yii debug or d...

yii2框架 yii2的asset資源包 十一

link license license use yii web assetbundle author qiang xue since 2.0 定義按需載入css方法,注意載入順序在最後 public static function addcss view,cssfile 將需要載入的檔案已陣列聚合...