【发布时间】:2019-06-10 11:34:29
【问题描述】:
我是 Laravel 的新手,我还不太清楚一切是如何运作的。我试图通过包含页面的开头将 appart 代码分成不同的部分,然后在该页面中创建一个 hero 部分,然后是一些 html。
一切都显示了,但页面上的 html 代码呈现在其他一切之上。
这个帖子看起来可能是事情没有被关闭,但我认为一切正常
Including header in wrong place Laravel 4
@include('blocks/scripts')
@extends('blocks/hero')
@section('title')
text here
@stop
@section('subtitle')
another text
@stop
<div class="container">
<div class="row">
<div class="col-12">
more text
</div>
<div class="col-6">
<h2 class="text-center">header</h2>
<p class="text-center">more text</p>
</div>
<div class="col-6">
<h2 class="text-center">header</h2>
<p class="text-center">more text</p>
</div>
</div>
</div>
@include('blocks/footer')
这是文件。 HTML 块在“脚本”之后立即呈现,然后是“页脚”,然后显示“英雄”。
顺序应该是scripts->hero->html->footer
@include('blocks/scripts') just has html code
@extends('blocks/hero') has @yield('title') and @yield('subtitle')
@include('blocks/footer') just text
【问题讨论】:
-
您能否在问题中添加模板
blocks/scripts.blade.php和blocks/hero.blade.php的外观? -
英雄长这样:
<div class="container-fuid mx-0 wlgx_hero"> <div class="row"> <div class="col-12"> @include('blocks/header') <section id="hero_text"> <h1 class="text-center text-white py-5">@yield('title')</h1> <hr class="purple_line pb-3"> <section id="subtitle"> <p class="text-center">@yield('subtitle')</p> </section> </section> </div> </div> </div> -
和脚本是这个加上一些用于引导的 cdn css 和一些字体:
<!doctype html> <html lang="{{ app()->getLocale() }}"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> -
blocks/header 只是有一个非常标准的引导导航栏,只是 html 没有雄辩的
标签: laravel laravel-blade