working with childrouts: ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment

working with childrouts: ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment

我遇到了这个错误,但不知道为什么。我希望你能帮助我。 我用 'Localhost:4200/Admin/Lastrecords'.

调用了 URL

错误错误:未捕获(承诺):错误:无法匹配任何路由。 URL 段.'Lastrecords'

parent.module

@NgModule({
  declarations: [
    AppComponent,
    InfoComponent,
    LoginComponent,
    ProtectedComponent,
    DropdownDirective,
    MainComponent
  ],
  imports: [
    BrowserModule,
    routing,],
    ...
    export class AppModule { }

parent.router

const APP_ROUTES: Routes = [
    {path: '', component: LoginComponent},
    {path: 'Admin', component: DashboardComponent, loadChildren: './admin/admin.module#AdminModule'},
];

export const routing = RouterModule.forRoot(APP_ROUTES);

child.module

@NgModule({
  declarations: [
    DashboardComponent,
    NewAccComponent,
    KeyComponent,
    LastLoginComponent,
    RecordComponent
  ],
  imports: [
    routdash,
    FormsModule,
  ],

   export class AdminModule {

}

child.routing

const DASH_ROUTES: Routes = [
  {path: '', component: LastLoginComponent, outlet: 'sec'},
  {path: 'Lastlogins', component: LastLoginComponent, outlet: 'sec'},
  {path: 'Lastrecords', component: RecordComponent, outlet: 'sec'},
];

export const routdash = RouterModule.forChild(DASH_ROUTES);

它不起作用的原因是您在子路由 ('sec') 中指定了一个(辅助)出口,所以 URL 应该是这样的:

http://localhost:4200/Admin(sec:Lastrecords)

更多信息:

https://angular.io/guide/router#secondary-routes