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

时间:2019-08-03 04:48:29

标签: php 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>

我正在从page目录中的signup.blade.php加载注册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

但是当我加载title时,既没有显示{strong>问题,也没有welcome.blade.php出现。

注意:标题显示为sign up form,不知道为什么?

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

1 个答案:

答案 0 :(得分:2)

您的主模板 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
相关问题