Laravel5.6(包含并产生)
Laravel5.6 (include and yield )
我在使用@include 和@yield 时遇到了问题...我稍微了解其中的区别,但不是很清楚。有人可以帮帮我吗??
- 什么时候应该使用@yield?
- 什么时候应该使用@include?
@include 将始终呈现视图
@yield 将根据您的路线呈现内容
例如您的 blade 有这些指令:
//home.blade.php
...
@include('header')
@yield('content')
...
@yield('content') will render a section having name content
@section('content')
....
//this will be rendered at @yield('content')
@endsection
include 将始终呈现头文件,但 yield 将呈现您从控制器发送的内容。
我在使用@include 和@yield 时遇到了问题...我稍微了解其中的区别,但不是很清楚。有人可以帮帮我吗??
- 什么时候应该使用@yield?
- 什么时候应该使用@include?
@include 将始终呈现视图
@yield 将根据您的路线呈现内容
例如您的 blade 有这些指令:
//home.blade.php
...
@include('header')
@yield('content')
...
@yield('content') will render a section having name content
@section('content')
....
//this will be rendered at @yield('content')
@endsection
include 将始终呈现头文件,但 yield 将呈现您从控制器发送的内容。