【问题标题】:Cannot find layout with laravel5laravel5 找不到布局
【发布时间】:2017-02-14 20:34:29
【问题描述】:

我收到此错误:

未找到视图 [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'));
});

【问题讨论】:

  • 您的 master.blade 位置:view/layouts/master.blade
  • @Komal 这正是问题所在

标签: php laravel blade


【解决方案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

【讨论】:

    【解决方案2】:

    master.blade.php放到这个目录下:

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

    或更改布局路径:

    @extends('layouts.master')
    

    到这里:

    @extends('master')
    

    【讨论】:

      猜你喜欢
      • 2019-11-30
      • 2019-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多