为什么 Blade 在渲染输出的部分之前包含下面显示的测试代码?有没有办法放在节后或节中?
// Specify the filename of the layout (without extension)
@extends('layout')
// The rest of the code of the view template
// Opening content section
@section('content')
// The content that will be injected in the layout replacing “@yield(‘content’)”
This is the home pagevvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Closing content section
@stop
@section('content')
<p>This is just Content</p>
@stop
@section('moreContent')
<p>This is More Content</p>
@stop
@section('evenMoreContent')
<p>This is Even More Content</p>
@stop
@include('navigation')
最佳答案
不,我认为没有办法做到这一点,并且当您扩展模板时,唯一呈现的是包含您定义的部分的 layout
。
如果你想改变输出的顺序,你可以在 layout
文件中做这件事。
您应该编辑扩展模板。您可以在 template
文件 (@yield('naveigation')
) 中添加另一个部分,稍后再定义 navigation
部分。
在这个文件中:
@section('navigation')
@include('navigation')
@stop
并且在 layout.blade.php
Layout
<br>
Nav:
<br>
@yield('navigation')
<br>
Content:
<br>
@yield('content')
关于php - Laravel Blade @include 在@section 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35297953/