路线不是定义的惯性。

发布于 2025-02-08 21:23:45 字数 300 浏览 2 评论 0原文

在我的控制器中,我有一种重定向到路由的方法:

return Redirect::route('/management');

这是我的routes/web.php

Route::get('/management', function () {
    return Inertia::render('Management');
});

但是,它引发了一个错误,说route [管理]未定义> 。

In my controller, I have a method to redirect to a route:

return Redirect::route('/management');

This is my routes/web.php:

Route::get('/management', function () {
    return Inertia::render('Management');
});

However, it throws an error saying Route [management] not defined.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惜醉颜 2025-02-15 21:23:45

redirect :: route()方法期望A 路由,您尚未在路由/web.php文件中定义的路由。

为了使用命名路线,您需要更改路线:

Route::get('/management', function () {
    return Inertia::render('Management');
})->name('management'); // added

之后,您可以将其重定向到惯性中的命名路线:

return Redirect::route('management');

由于我们使用命名路由,而不是URL,因此您不应包括领先的/在您的route()呼叫中。

The Redirect::route() method expects a named route, which you have not defined in your routes/web.php file.

In order to use a named route, you need to change your route to:

Route::get('/management', function () {
    return Inertia::render('Management');
})->name('management'); // added

After that, you can redirect to named routes in Inertia like so:

return Redirect::route('management');

Since we're using named routes, and not URLs, you should not include the leading / in your route() call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文