0

我一直在尝试太多的方法并坚持新的场景

下面是我的 app.module.ts

export const ROUTES: Routes=[
    { 
      path: '', component: LoginComponent},
    { 
      path: 'maincontent', 
      loadChildren: './main-content/maincontent.module#MainContentModule'
    }]

下面是我的 maincontent.module.ts

export const ROUTES: Routes = [
  {
    path: 'maincontent',
    component: MainContentComponent,
    children: [
      { path: 'dashboard', 
        loadChildren: './dashboard/dashboard.module#DashboardModule' },
    ] 
      }];

在 dashboard.module.ts 我有以下路线

export const ROUTES: Routes = [
  {
    path:'dashboard', component:DashboardComponent,
    children:[
      {
        path:'application',component:ApplicationDetailsComponent
      }
    ]
  }
]

问题是当我登录时,我直接导航到仪表板页面,它没有显示页面的任何内容。我哪里错了,请谁能指导我

4

2 回答 2

1

我正在经历类似的事情,但事实证明,我错过了一个依赖......

在您的情况下,@yurzui 答案看起来是正确的。

于 2018-05-08T21:42:21.367 回答
0

我认为您应该将path子路由设置为空字符串

maincontent.module.ts

export const ROUTES: Routes = [
  {
    path: '', // instead of path: 'maincontent',
    component: MainContentComponent,
    children: [
      {
        path: 'dashboard',
        loadChildren: './dashboard/dashboard.module#DashboardModule'
      },
    ]
  }];

仪表板.module.ts

export const ROUTES: Routes = [
  {
    path: '', // instead of path: 'dashboard'
    component: DashboardComponent,
    children: [
      {
        path: 'application', component: ApplicationDetailsComponent
      }
    ]
  }
]

Plunker 示例

于 2017-08-18T18:50:35.257 回答