laravel @include 不工作
laravel @include not working
我正在尝试使用 blade 语法
在我的用户页面中包含文件
@include('header')
@yield('content')
@include('footer')
这里是web.php
Route::get('/', function () {
return view('layouts.user');
});
我遇到了这个错误
(1/1) InvalidArgumentException View [layouts.user] not found.
这是因为您应该包含视图文件夹的完整路径,所以它看起来像这样:
@include('user.layouts.header')
@include('user.layouts.footer')
您始终必须使用视图的绝对路径。所以在你的情况下,这应该是:
@include('user.layouts.header')
@yield('content')
@include('user.layouts.footer')
您的路由文件的计数相同:
Route::get('/', function () {
return view('user.layouts.user');
});
我正在尝试使用 blade 语法
在我的用户页面中包含文件@include('header')
@yield('content')
@include('footer')
这里是web.php
Route::get('/', function () {
return view('layouts.user');
});
我遇到了这个错误
(1/1) InvalidArgumentException View [layouts.user] not found.
这是因为您应该包含视图文件夹的完整路径,所以它看起来像这样:
@include('user.layouts.header')
@include('user.layouts.footer')
您始终必须使用视图的绝对路径。所以在你的情况下,这应该是:
@include('user.layouts.header')
@yield('content')
@include('user.layouts.footer')
您的路由文件的计数相同:
Route::get('/', function () {
return view('user.layouts.user');
});