【问题标题】:Angular default router outletAngular 默认路由器插座
【发布时间】:2020-03-28 15:31:59
【问题描述】:

我有用户模块,我正在尝试加载默认路由器插座。 当路径为 /user 但它不起作用时,我想加载 UserHomeComponent 。如果我添加路径而不是将其保持为空,则它可以正常工作。 这是我的用户路由模块:

const routes:Routes = [
    {path: 'user' ,  component: UserComponent , children:[
        {path: '' , component: UserHomeComponent},
        {path: 'new-request' , component: NewRequestComponent},
        {path: 'checkout' , component: CheckoutComponent},
        {path: 'edit-info' , component: UserEditInfoComponent},
        {path: 'requests', component: UserRequestsComponent},
        {path: 'change-password' , component: UserChangePasswordComponent},
        {path: 'delete-account' , component: DeleteAccountComponent}
    ]}
]

这是我的应用路由模块:

const appRoutes:Routes = [
    {path: '' , redirectTo: 'login' , pathMatch: 'full'},
    {path: 'login' , component: LoginComponent },
    {path: 'signup' , component: SignupComponent},
    {path: 'user' , loadChildren: () => import('./user/user.module').then(m => m.userModule)},];

【问题讨论】:

  • 请定义“它不工作”。你看到了什么错误?

标签: angular path default router outlet


【解决方案1】:

要加载 UserHomeComponent,请更改此项

{path: 'user' ,  component: UserComponent , children:[

{path: '' ,  component: UserComponent , children:[

【讨论】:

    猜你喜欢
    • 2018-04-02
    • 2018-07-28
    • 1970-01-01
    • 2016-12-30
    • 2018-09-27
    • 2019-01-05
    • 2018-12-15
    • 2017-03-09
    • 2018-08-18
    相关资源
    最近更新 更多