【问题标题】:@yield and @section is not working@yield 和 @section 不起作用
【发布时间】:2017-11-18 18:56:54
【问题描述】:
this is the code in the main.blade.php so i place an @yield('content') inside the div tags of my bootstrap template but it's that getting the display that should be on the home.blade.php

<div class="container">
     @yield('content')
</div>

this is the code on my home.blade.php

@extends('main')

@section('content')
<div class="row">
    <h1>this content should show on my main</h1>
</div>
@endsection

I dont know why its not working it seems like the @yield and @section is not working by the I'm using laravel 5.4 and it's not displaying any error then what could be wrong

I dont know why its not working it seems like the @yield and @section is not working by the I'm using laravel 5.4 and it's not displaying any error then what could be wrong

我不知道为什么它不起作用,我使用 laravel 5.4 似乎 @yield 和 @section 不起作用并且它没有显示任何错误,那么可能是什么问题

【问题讨论】:

    标签: twitter-bootstrap laravel layout laravel-blade


    【解决方案1】:

    您不应该在一个文件中使用所有这些指令。例如,在布局文件中使用@yield,然后在由控制器路由呈现的视图中使用@extend。 @section 与它们填充的应用布局的相应区域对齐。

    【讨论】:

    • 这就是我所做的,我将@yield 放在我的 main.blade.php 和我的 home.blade.php 上,我将 @section('content')
    猜你喜欢
    • 2017-07-13
    • 2021-03-29
    • 2017-11-18
    • 2021-06-06
    • 1970-01-01
    • 2015-05-18
    • 2019-01-12
    • 2021-09-27
    • 1970-01-01
    相关资源
    最近更新 更多