Yii2 选择布局的方式

方案1:控制器内成员变量

public $layout = false; //不使用布局
public $layout = "main"; //设置使用的布局文件

方案2:控制器成员方法内

$this->layout = false; //不使用布局
$this->layout = "main"; //设置使用的布局文件

方案3:视图中选择布局

$this->context->layout = false; //不使用布局
$this->context->layout = 'main'; //设置使用的布局文件


附视频:http://pan.baidu.com/s/1kTMhGqV

问题:

解决方案一,在controller中设置:

解决方案二:views中设置

。。。。。。
posted @ 2016-10-24 13:50  侠岚之弋痕夕  阅读(512)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!