如果我重新加载页面 (F5) 或将其打开到新选项卡中,我想使用相同的路线。
例如,我使用以下路线:
http://localhost:4200/show-category/-KmhdoAJO0WQbTzS9gll
如果我按 F5 这是结果:
http://localhost:4200/
问题是它显示与以前相同的组件,但由于缺少 id 没有值。应用程序崩溃。
(我在另一个问题上坐了几个小时,也许我现在还不够专注,无法找到错误。)
我希望有一个人可以很快帮助我。
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'access-denied', component: AccessDeniedComponent },
{ path: 'add-category', component: AddCategoryComponent },
{ path: 'add-reply/:id', component: AddReplyComponent },
{ path: 'add-topic/:id', component: AddTopicComponent },
{ path: 'change-user-roles', component: ChangeUserRolesComponent },
{ path: 'edit-category/:id', component: EditCategoryComponent },
{ path: 'edit-reply/:id', component: EditReplyComponent },
{ path: 'edit-topic/:id', component: EditTopicComponent },
{ path: 'delete-category/:id', component: DeleteCategoryComponent },
{ path: 'delete-reply/:id', component: DeleteReplyComponent },
{ path: 'delete-topic/:id', component: DeleteTopicComponent },
{ path: 'register-user', component: RegisterUserComponent },
{ path: 'show-category/:id', component: ShowCategoryComponent },
{ path: 'show-topic/:id', component: ShowTopicComponent },
{ path: 'user-profile', component: UserProfileComponent },
]