0

我有以下文件views/errors/404.blade.php

Error Here!

当我输入不正确的 URL 时,它按预期工作(我只看到“此处出错!”文本)。

但是,如果我更新文件以包含以下内容:

@extends('layouts.page')

@section('title', @trans('general.error'))

@section('content')

    Error here!

@endsection

我确实收到了“此处出错”消息,但我也看到了“哎呀,看起来出了点问题”。消息和 HTML 都搞砸了。指定的布局 (layouts/page.blade.php) 存在并且是我用于所有其他视图的布局。

知道为什么会这样吗?

提前致谢!

4

1 回答 1

0

问题是该page.blade.php文件包含以下内容:

@if(App::environment('local', 'staging'))
    Current route: {{ Route::getCurrentRoute()->getName() }}<br/>
@endif

如果我删除Current route: {{ Route::getCurrentRoute()->getName() }}<br/>它按预期工作的部分。

无需过多挖掘,我的猜测是getCurrentRoute()返回 null。

于 2017-03-18T20:56:24.270 回答