Laravel:找不到 Layouts.master
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42478785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: Layouts.master not found
提问by Feralheart
I built the demosite in Laravel, but I got the following error:
我在 Laravel 中构建了演示站点,但出现以下错误:
ErrorException in FileViewFinder.php line 137: View [layouts.master] not found.(View: /var/www/html/project/laravel/laravel/resources/views/page.blade.php)
FileViewFinder.php 第 137 行中的 ErrorException:未找到视图 [layouts.master]。(视图:/var/www/html/project/laravel/laravel/resources/views/page.blade.php)
The master.blade.php is next to the page.blade.php, both are in resources/views
master.blade.php 在 page.blade.php 旁边,都在资源/视图中
master.blade.php
master.blade.php
<html>
<head>
<title>@yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@section('content')
</div>
</body>
</html>
page.blade.php
页面.blade.php
@extends('layouts.master')
@yield('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<h2>{{$name}}</h2>
<p>This is my body content.</p>
@endsection
What goes wrong? I working from this tutorial.
回答by EddyTheDove
Try
尝试
@extends('master')
They are both at the views
root you said. Or create a directory called layouts
and place master.blade.php
inside.
他们都是views
你说的根源。或者创建一个名为的目录layouts
并放在master.blade.php
里面。
UpdatesIn your master.blade.php
where you want your content
to be "injected", do:
更新在您master.blade.php
希望content
“注射”的地方,请执行以下操作:
@yield('content')
//remove @section('content') because your master does not extends any other layout
The exact same way you did with @yield('title')
.
与您对@yield('title')
.
回答by Mayank Pandeyz
When you are using @extends('layouts.master')
means your view searches for the master
layout under resources/views/layouts
directory.
当您使用时,@extends('layouts.master')
意味着您的视图会搜索目录master
下的布局resources/views/layouts
。
So make sure the master
layout exist under the resources/views/layouts
directory.
所以确保master
布局存在于resources/views/layouts
目录下。