繁体   English   中英

布局不包含在Laravel的主文件中

[英]Layout is not including in the main file in Laravel

我有一个主文件welcome.blade.php ,在其中标记了这样的内容

<!DOCTYPE html>
    <html>
    <head>
        <title>
            @yield('title')    // title from signup.blade.php
        </title>
    </head>
    <body>

        <!-- some content here -->


         @yield('signup')    // I'm loading this from signup.blade.php



        <!-- some content here -->

    </body>
    </html>

我正在从signup.blade.php加载注册page ,该page位于目录layouts/signup.blade.php

signup.blade.php页面的代码如下:

@include('welcome')

@section('title')

    measurement

@endsection

@section('signup')
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <form action="">
                <input type="text" class="form-control">
            </form>
        </div>
    </div>
</div>

@endsection

文件的结构如下:

resources/views/welcome.blade.php

resources/views/layouts/signup.blade.php

但是问题是当我加载welcome.blade.php时, title都没有显示,也没有sign up form出现。

注意:标题显示localhost:8000 ,不知道为什么?

我做错什么了,请帮我谢谢。

您的主模板welcome.blade.php

<!DOCTYPE html>
<html>
    <head>
        <title>
            @yield('title')
        </title>
    </head>
    <body>
         @yield('content')
    </body>
</html>

现在,将使用此模板的任何页面都需要对其进行扩展。 在您的情况下signup.blade.php

@extends('welcome')

@section('title')

    measurement

@endsection

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <form action="">
                <input type="text" class="form-control">
            </form>
        </div>
    </div>
</div>

@endsection

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM