【发布时间】:2018-09-16 07:22:57
【问题描述】:
我在使用@include 和@yield 时遇到了问题...我稍微了解其中的区别,但并不清楚。那么有人可以帮助我吗??
- 什么时候应该使用@yield?
- 什么时候应该使用@include?li>
【问题讨论】:
-
查看我的回答 here,它解释了 to 方法之间的区别。
我在使用@include 和@yield 时遇到了问题...我稍微了解其中的区别,但并不清楚。那么有人可以帮助我吗??
【问题讨论】:
@include 将始终呈现视图
@yield 将根据您的路线呈现内容
例如,您的刀片具有以下指令:
//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 将呈现您从控制器发送的内容。
【讨论】: