Fer*_*art 2 php laravel laravel-5
我在Laravel中构建了demosite,但是我收到了以下错误:
FileViewFinder.php第137行中的ErrorException:未找到视图[layouts.master].(查看:/var/www/html/project/laravel/laravel/resources/views/page.blade.php)
master.blade.php位于page.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>
Run Code Online (Sandbox Code Playgroud)
page.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
Run Code Online (Sandbox Code Playgroud)
尝试
@extends('master')
Run Code Online (Sandbox Code Playgroud)
他们都是views你所说的根.或者创建一个名为的目录layouts并放在master.blade.php里面.
更新
在您master.blade.php希望content"注入"的位置,执行以下操作:
@yield('content')
//remove @section('content') because your master does not extends any other layout
Run Code Online (Sandbox Code Playgroud)
你用的方式完全一样@yield('title').
当您使用时@extends('layouts.master')意味着您的视图会搜索下的master布局resources/views/layouts目录。
所以确保master布局存在于resources/views/layouts目录下。
| 归档时间: |
|
| 查看次数: |
5221 次 |
| 最近记录: |