在使用Laravel的主布局中,输出为空白



我是Laravel的新手,我正在为Laravel刀片使用模板布局继承,这是我的代码,在浏览器上打招呼很简单。但是运行完这个之后,我的输出显示为空白。浏览器或控制台窗口上没有显示错误。请帮我找出我的错误。

masterblade.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>master page</title>
</head>
<body>
<div>
@yield('content')
</div>
</body>
</html>

body.blade.php

@extends('master')
@section('content')
<h1> Hello </h1>
@endsection

studentcontroller.php

public function viewmasterpage()
{
return view('master');
}

web.php

Route::get('/masterpage','studentcontroller@viewmasterpage')->name('masterpage');

您在studentcontroller中返回master布局,因为您将找不到任何需要返回的body,它扩展了master布局并包含<h1> Hello </h1>

public function viewmasterpage()
{
return view('body');
}

最新更新