我正在尝试一些非常简单的事情,但不能让它起作用。
我有两页。admin.blade.php和left.blade.php
我正在尝试使用管理页作为母版页。并包含来自left.blade.php的日期
管理页面只打印“test”作为结果,不包含left.admin.php中的任何内容。
我看不出哪里出了问题。提前谢谢
文件结构是
-- resources
--views
*admin.blade.php
*left.blade.php
左.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命令是
Route::get('/admin', function () {
return view('admin');
});
最佳答案
如果您想在left.blade.php
中包含日期,您应该在@include()
中使用admin.blade.php
指令:
@include('left')
如果您的主要内容位于
left.blade.php
中,并且您仅使用admin.blade.php
作为布局,则更改您的路由:Route::get('/admin', function () {
return view('left');
});