未找到查看 [layouts.app]。Laravel 框架 5.4.36
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48836709/
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
View [layouts.app] not found. Laravel Framework 5.4.36
提问by Filip123go
I am having a problem using Laravel Framework 5.4.36 (on Visual studio code). I am trying to build a simple layout, but no mater how much I've tried I am getting the same error on my browser :
我在使用 Laravel Framework 5.4.36(在 Visual Studio 代码上)时遇到问题。我正在尝试构建一个简单的布局,但是无论我尝试了多少次,我的浏览器都遇到了同样的错误:
View [layouts.app] not found. (View: C:\wamp64\www\lsapp\resources\views\pages\services.blade.php)
未找到查看 [layouts.app]。(查看:C:\wamp64\www\lsapp\resources\views\pages\services.blade.php)
as you can see (photo bellow) the file is deferentially there, in the right path.
Here is my code for my layout app.blade.php :
这是我的布局 app.blade.php 的代码:
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{config('app.name','LSAPP')}}</title>
</head>
<body>
@yield('content')
</body>
and here is my code from services.blade.php
这是我来自 services.blade.php 的代码
@extends('layouts.app')
@section('content')
<h1>services</h1>
<p>This is the services page</p>
@endsection
I have also installed Laravel Blade Snippets v 1.13.0 (1.14.1 was giving me another problem).
我还安装了 Laravel Blade Snippets v 1.13.0(1.14.1 给了我另一个问题)。
I have tried to change name and path both to the layout file and inside the extends parameter. Any ideas why this is not working?
我试图更改布局文件和扩展参数内部的名称和路径。任何想法为什么这不起作用?
Thank you very much in advance for your help..!
非常感谢您的帮助..!
回答by sam
You must reference a blade template relative to the resources/views
directory. According to the screenshot your directory structure is:
您必须引用与resources/views
目录相关的刀片模板。根据屏幕截图,您的目录结构是:
resources
?views
?pages
?layouts
app.blade.php
Therefore your app.blade.php
layout is available as pages.layouts.app
:
因此,您的app.blade.php
布局可用作pages.layouts.app
:
@extends('pages.layouts.app')
回答by Prince Lionel N'zi
Change
改变
@extends('layouts.app')
To
到
@extends('pages.layouts.app')
回答by Mayank Sahu
The problem is you put 'layouts' folder inside 'pages', actually, it should be inside view only.
问题是您将“布局”文件夹放在“页面”中,实际上,它应该仅在视图中。
directory structure should be:
目录结构应该是:
-view -layouts -pages
-view -layouts -pages