【问题标题】:Twig reports "An exception has been thrown during the rendering of a template" in LaravelTwig 在 Laravel 中报告“在渲染模板期间引发了异常”
【发布时间】:2019-12-02 02:23:45
【问题描述】:

我在 Laravel 中遇到了这个错误:

Twig \ Error \ RuntimeError 在运行过程中抛出了异常 模板的呈现(“路线 [shortname.shortname_list] 不是 定义。”)在第 154 行的“common.sidebar.vendor.twig”中。

我已经检查了我的 sidebar.twig、路由列表和控制器,看起来还不错。

这个错误是什么意思,有什么可能的解决方案?

【问题讨论】:

    标签: php laravel laravel-5 twig


    【解决方案1】:

    此错误表示您的路由配置中未定义名为 shortname.shortname_list 的路由。

    您需要确保您有一个名为 shortname.shortname_list 的路由才能在 twig 中为其生成 URL。

    Route::get('route-path', ['uses' => 'Controller@method'])
        ->name('shortname.shortname_list');
    

    【讨论】:

    • 我的路由列表中已经有了它,我只是想知道为什么即使我在 web.php 文件中声明它仍然会发生这种情况。 Route::get('catalog/plan/price/list', 'ShortnamesController@shortname_list')->name('shortname.shortname_list');
    • 它在路由组内吗?你能检查php artisan route:list的输出吗?
    • 是的,它在路由列表中。 (dochub.com/bricxcarasco-gss/p7e92j/…)
    猜你喜欢
    • 2018-12-25
    • 1970-01-01
    • 2015-05-25
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多