laravel @include 不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46031607/
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 @include not working
提问by Anik Biswas
I am trying to include files in my user page using blade syntax
我正在尝试使用刀片语法在我的用户页面中包含文件
@include('header')
@yield('content')
@include('footer')
here is web.php
这是 web.php
Route::get('/', function () {
return view('layouts.user');
});
i'm getting this error
我收到这个错误
(1/1) InvalidArgumentException View [layouts.user] not found.
(1/1) InvalidArgumentException 查看 [layouts.user] 未找到。
回答by Jerodev
You always have to use the absolute path to a view. So in your case, this should be:
您始终必须使用视图的绝对路径。所以在你的情况下,这应该是:
@include('user.layouts.header')
@yield('content')
@include('user.layouts.footer')
The same counts for your routes file:
路由文件的计数相同:
Route::get('/', function () {
return view('user.layouts.user');
});
回答by Martin
It's because you should include full path from the view folder so it will look like this:
这是因为您应该包含视图文件夹中的完整路径,因此它看起来像这样:
@include('user.layouts.header')
@include('user.layouts.footer')