将标题包含在错误位置 Laravel 4

3
我试图先包含header.blade.php,然后再包含内容,但它的包含方式是错误的。

<!DOCTYPE html>
<html>
 <head>
 </head>
 <body>
  <!-- include navbar / header -->
  @include('site.components.header')
  <!-- content -->
  @yield('content')
  <!-- footer -->
  @include('site.components.footer')
 </body>
</html>

渲染后,HTML内容包含在头部之前。

删除您的HTML标签。http://laravel.com/docs/5.0/templates - IshaS
你的其他页面中是否有带有 @section@stop 的内容? - rap-2-h
@Isahas 为什么要删除 HTML 标签? - rap-2-h
谢谢!我的内容部分没有@stop。 - Buglinjo
1个回答

1
当您创建一个可以包含内容的部分时,您需要像这样停止它:
  @section('name of section here')
      //Your customized content for this section.
  @stop

@show 会立即输出这个内容,也就是结束当前部分并把它呈现出来。Yielding 意味着这是输出该部分内容的点。

  @section('name of section here')
      //Your customized content for this section.
  @show

谢谢!它帮了很多忙! - Buglinjo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接