Vue js laravel 8 routing



当我试图在vue路由器中添加路由路径时,我仍然感到困惑,例如:

{
path: '/admin/blog/archived_blogs',
name: 'ArchivedBlogs',
meta: { title: 'Archived Blog' },
component: ArchivedBlog
},

除了删除我出错的地方外,一切都很好405(不允许使用方法(

此路由不支持POST方法。支持的方法:GET,HEAD。

我所能做的就是更改的路径

{
path: '/admin_blog_archived_blogs',
name: 'ArchivedBlogs',
meta: { title: 'Archived Blog' },
component: ArchivedBlog
},

我目前使用的网络路由是

Route::get('/{slug?}', [HomeController::class, 'index'])->where('slug', '[/w.-]*')->name('home');

有什么建议吗?

您需要使用any()来捕获所有方法以及

Route::any('/{slug?}', [HomeController::class, 'index'])->where('slug', '[/w.-]*')->name('home');

对于SPA,我使用

Route::any('{all}', [HomeController::class, 'index'])
->where('all', '^(?!api).*$')
->where('all', '^(?!storage).*$');

像这样,所有与web相关的路由句柄Vuejsstorageapi路由都由laravel 处理

最新更新