Laravel 布局不工作

Laravel layouts not working

我正在尝试一些非常简单的事情,但无法让它工作。 我有 2 页。 admin.blade.php 和 left.blade.php 我正在尝试使用管理页面作为母版页。并包括 left.blade.php

的日期

管理页面仅打印 "test" 作为结果,不包含任何来自 left.admin.php 的内容。 我看不出有什么问题。提前致谢

文件结构为

-- resources
   --views
     *admin.blade.php
     *left.blade.php

left.blade.php

@extends('admin')

@section('content')
   baran
@stop

admin.blade.php

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
    <title> @yield('title')</title>
</head>
<body>
    <?php
    // put your code here
    ?>

    @yield('content')

    test
<div id='footer'>
    @yield('footer')
</div>
</body>
</html>

web.php 中的路由命令是

Route::get('/admin', function () {
    return view('admin');
});

如果您想包含来自 left.blade.php 的日期,您应该在 admin.blade.php 中使用 @include() 指令:

@include('left')

如果您的主要内容在 left.blade.php 中并且您仅使用 admin.blade.php 作为布局,那么请更改路线:

Route::get('/admin', function () {
    return view('left');
});

您想为内页调用视图,而不是母版页,因为内页扩展了母版页:

return view('left');