在L4中可以在controller中定义 $layout模板,然后在请求中使用
<code>$this->layout->content = View::make(sth view)</code>
今天在L5.3中使用不行,各位有什么解决办法吗
本2文来*源gao($daima.com搞@代@#码(网搞gaodaima代码
回复内容:
在L4中可以在controller中定义 $layout模板,然后在请求中使用
<code>$this->layout->content = View::make(sth view)</code>
今天在L5.3中使用不行,各位有什么解决办法吗
真的很抱歉,我从来没有使用过L4
Laravel 5 中 Controller
是一个空白的类,里面没有任何的变量,包括layout
个人建议重新阅读手册查看view的使用方法:https://laravel-china.org/doc…(中文)
5 中很多做了升级和变革,要重新学习。
如果在 Laravel 5
尝试以下方式使用看看,就是把字段变成方法
<code>// 在 controller 中设置原本4中设置的 $layout 视图值public $layout_path = 'view_path';// 提供一个方法获取 layout 视图public function layout(){ return view($this->layout_path);}// 使用( 将原本的$this->layout 改成 $this->layout() )$this->layout()->content = View::make(sth view);</code>