【问题标题】:laravel @include not workinglaravel @include 不工作
【发布时间】:2018-02-12 08:53:24
【问题描述】:
我正在尝试使用刀片语法在我的用户页面中包含文件
@include('header')
@yield('content')
@include('footer')
这里是 web.php
Route::get('/', function () {
return view('layouts.user');
});
我收到了这个错误
(1/1) InvalidArgumentException 未找到视图 [layouts.user]。
【问题讨论】:
标签:
php
laravel
laravel-5.4
laravel-blade
【解决方案1】:
您始终必须使用视图的绝对路径。所以在你的情况下,这应该是:
@include('user.layouts.header')
@yield('content')
@include('user.layouts.footer')
路由文件的计数相同:
Route::get('/', function () {
return view('user.layouts.user');
});
【解决方案2】:
这是因为您应该包含视图文件夹的完整路径,所以它看起来像这样:
@include('user.layouts.header')
@include('user.layouts.footer')