【问题标题】: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')
      

      【讨论】:

        猜你喜欢
        • 2014-02-23
        • 2014-03-06
        • 2016-11-30
        • 1970-01-01
        • 2017-12-05
        • 2013-02-09
        • 1970-01-01
        • 1970-01-01
        • 2015-07-06
        相关资源
        最近更新 更多