【问题标题】:Default path in a path with children带有子项的路径中的默认路径
【发布时间】:2019-01-20 07:42:29
【问题描述】:

我使用 angular 6,对于应用程序的 cms,我在 app.modules.ts 文件中设置了以下路径。

{ path: 'cms', component: CmsComponentComponent, children: [
  { path: 'register', component: RegisterComponent },
  { path: 'login', component: LoginComponent },
  { path: 'profile', component: ProfileComponent, canActivate:[AuthGuard] },
  { path: 'educate', component: EducateComponent, canActivate:[AuthGuard] }
]},

我想要一个默认的cms,所以如果我输入app/cms,我就必须注册。

我该怎么做?

谢谢

【问题讨论】:

    标签: angular angular6 angular-routing


    【解决方案1】:

    据我了解,您只需添加这样的重定向路由:

    { path: 'cms', component: CmsComponentComponent, children: [
      { path: 'register', component: RegisterComponent },
        ...
      { path: '', redirectTo: '/register', pathMatch: 'full' }
    ]},
    

    【讨论】:

      猜你喜欢
      • 2012-02-02
      • 1970-01-01
      • 2012-01-23
      • 2022-09-27
      • 2023-02-21
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      相关资源
      最近更新 更多