在l4中可以在controller中定义 $layout模板,然后在请求中使用
$this->layout->content = view::make(sth view)
今天在l5.3中使用不行,各位有什么解决办法吗
回复内容: 在l4中可以在controller中定义 $layout模板,然后在请求中使用
$this->layout->content = view::make(sth view)
今天在l5.3中使用不行,各位有什么解决办法吗
真的很抱歉,我从来没有使用过l4
laravel 5 中 controller 是一个空白的类,里面没有任何的变量,包括layout
个人建议重新阅读手册查看view的使用方法:https://laravel-china.org/doc...(中文)
5 中很多做了升级和变革,要重新学习。
如果在 laravel 5 尝试以下方式使用看看,就是把字段变成方法
// 在 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);