Yii2 模板布局使用

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

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

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

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

方案3:视图中选择布局

$this->context->layout = false; //不使用布局
$this->context->layout = 'main'; //设置使用的布局文件
原文地址:https://www.cnblogs.com/zjj1990/p/8431775.html