用laravel5找不到布局

时间:2016-10-06 07:37:28

标签: php laravel blade

我收到此错误:

未找到查看[layouts.master]。 (查看:C:\ xampp5 \ htdocs \ laravel \ laravel \ resources \ views \ 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">
    @yield('content')
</div>

</body>
</html>

这是page.blade.php:

@extends('layouts.master')
@section('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

以下是路线的相关部分:

Route::get('blade', function () {
    return view('page',array('name' => 'Random Name'));
});

2 个答案:

答案 0 :(得分:6)

master.blade.php放在此目录中:

C:\xampp5\htdocs\laravel\laravel\resources\views\layouts

或更改布局的路径:

@extends('layouts.master')

到此:

@extends('master')

答案 1 :(得分:1)

这样做

@extends('master')
@section('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