Yii2 选择布局的方式

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

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

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

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

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

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

方案3:视图中选择布局

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

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

https://blog.csdn.net/YPLee_8/article/details/52292314

猜你喜欢

转载自blog.csdn.net/benben0729/article/details/81775224