【问题标题】:Including header in wrong place Laravel 4在错误的地方包括标题Laravel 4
【发布时间】:2015-08-10 11:20:41
【问题描述】:

我试图先包含 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标签。laravel.com/docs/5.0/templates
  • 您的其他页面中是否有带有@stop@section 内容?
  • @Isahas 为什么要删除 html 标签?
  • 谢谢!我的内容部分没有@stop。

标签: php laravel include blade


【解决方案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

【讨论】:

  • 谢谢!帮了大忙!
猜你喜欢
  • 2017-08-01
  • 2023-03-25
  • 1970-01-01
  • 2013-08-17
  • 1970-01-01
  • 1970-01-01
  • 2014-04-20
  • 2014-08-16
  • 1970-01-01
相关资源
最近更新 更多