3

我有命名路由器出口和延迟加载模块的问题。我有 2 个路由器插座,第一个没有名字,第二个名为mainapp

app.component.html

<router-outlet></router-outlet>

app.main.component.html

<router-outlet name="mainapp"></router-outlet>

应用程序.routes.ts

export const routes: Routes = [
    {path: 'login',  component: LoginComponent},
    {path: 'app', component: AppMainComponent, children:[
        {path: '', loadChildren: 'app/client/client.module#ClientModule'}
    ]}
];

客户端.module.ts

@NgModule({
  imports: [
    SharedModule,
    RouterModule.forChild([
      {path: 'client', component: ClientListComponent, outlet: "mainapp" },
      {path: 'client/:id', component: ClientComponent, outlet: "mainapp" }
    ])
  ],
  declarations: [ClientListComponent, ClientComponent],
  exports: [ClientListComponent, ClientComponent]
})
export class ClientModule { }
  1. LoginComponent 被加载到路由器出口
  2. 登录后 AppMainComponent 被加载到路由器出口
  3. 现在我尝试将 ClientComponent 加载到命名路由器插座mainapp

我收到错误

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'app'
Error: Cannot match any routes. URL Segment: 'app

当我修改路线时,它可以工作:

export const routes: Routes = [
    {path: 'login',  component: LoginComponent},
    {path: 'app', component: AppMainComponent, children:[
        {path: 'client', component: ClientListComponent, outlet: "mainapp" },
        {path: 'client/:id', component: ClientComponent, outlet: "mainapp" }
    ]}
];
4

1 回答 1

1

似乎是您可以在以下位置关注的已知错误: https ://github.com/angular/angular/issues/10981

于 2018-03-19T16:03:18.520 回答