1
在许多示例和文档中,我通常会看到页面标题是通过someController-> main.blade.php-> somePage.blade.php设置的。喜欢的东西:在laravel中设置页面元标题的正确方法是什么
SomeController.php
public function someAction()
{
$title = 'Some Title';
return view('somePage', ['title'=>$title]);
}
main.blade.php
<head>
<title> @section('title') | Page @show </title>
...
somePage.blade.php
@section ('title')
{{$title}} @parent
@endsection
岂不是模式方便地设置它直接/仅在控制器和刀片布局文件上?我的意思是这样的:
SomeController.php
public function someAction()
{
$title = 'Some Title';
return view('somePage', ['title'=>$title]);
}
main.blade.php
<head>
<title>{{ $title }}</title>
...
那岂不是更好地以这种方式来使用它?