【发布时间】:2022-01-06 10:54:40
【问题描述】:
我想实现用户个人资料页面。只需使用
/profile/user123 路径使用:
app-routing.module
{
path: 'profile',
loadChildren: () => import('./modules/profile/profile.module').then(m => m.ProfileModule)
},
profile-routing.module
{
path: ':username',
component: ProfileComponent
},
但是,我想做一些花哨的 URL,例如 /@user123。
不幸的是,我没有找到任何关于如何做到这一点的线索。我尝试了以下方法:
app-routing.module
{
path: '@:username',
loadChildren: () => import('./modules/profile/profile.module').then(m => m.ProfileModule)
},
profile-routing.module
{
path: '',
component: ProfileComponent
},
但是没有用。
我想到的只有一件事,那就是使用 Guard 检查“@”前缀,否则重定向到 /not-found 页面。
关于如何使用“Angular”方式进行路由的任何想法?
【问题讨论】:
标签: angular typescript routes router prefix