Laravel 我如何在 blade 中获取带有名称的路由

Laravel how i get route with name in blade

我也有这样的路线

Route::group(['prefix'=>LaravelLocalization::setLocale(),
    'as'=>'front.',
    'middleware'=>['localeSessionRedirect','localizationRedirect',]],function ()
{
    Route::get('/view/post/{id}', [ExtraController::class, 'SinglePost'])->name('post_view');
});

所以我想在 blade.How 中调用这条路线,我得到 post_view 路线?

在你的视图中尝试这个:

//example:
<a href="{{route('post_view', $post->id)}}">
<a href="{{route('post_view', [$post->id])}}">