简体   繁体   English

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

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

I've the main file which is welcome.blade.php where I've mark up something like this 我有一个主文件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>

I'm loading sign up page from signup.blade.php which is in directory layouts/signup.blade.php . 我正在从signup.blade.php加载注册page ,该page位于目录layouts/signup.blade.php

signup.blade.php page has code something like this: 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

The structure of the files is like this : 文件的结构如下:

resources/views/welcome.blade.php

resources/views/layouts/signup.blade.php

But the problem is neither the title is showing when I load welcome.blade.php neither the sign up form appears. 但是问题是当我加载welcome.blade.php时, title都没有显示,也没有sign up form出现。

Note: The title is showing localhost:8000 , don't know why ? 注意:标题显示localhost:8000 ,不知道为什么?

Am I doing anything wrong, please help me thanks. 我做错什么了,请帮我谢谢。

Your master template welcome.blade.php 您的主模板welcome.blade.php

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

And now any page that will use this template need to extends it. 现在,将使用此模板的任何页面都需要对其进行扩展。 In your case signup.blade.php 在您的情况下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