我对延迟加载有疑问。使用Augury检测我的路由器树结构。
app-routing.module.ts
const routes: Routes = [
{
path: '',
children: [
{
path: 'reservation',
loadChildren: () => import('./modules/reservations/reservations.module').then(mod => mod.ReservationsModule)
},
{
path: 'add',
loadChildren: () => import('./modules/add-autopoint/add-autopoint.module').then(mod => mod.AddAutopointModule)
},
{
path: 'availability',
loadChildren: () => import('./modules/availability/availability.module').then(mod => mod.AvailabilityModule)
},
{
path: 'archive',
loadChildren: () => import('./modules/archive/archive.module').then(mod => mod.ArchiveModule)
},
{ path: '**', redirectTo: '/reservation', pathMatch: 'full' },
]
}
];
示例模块路由
reservation-routing.module.ts
const routes: Routes = [
{ path: '', component: ReservationComponent },
{ path: 'summary/:id', component: SummaryComponent, resolve: { summary: AtplSummaryResolver, notes: AtplNotesResolver } }
];
app.module.ts
@NgModule({
declarations: [
AppComponent,
FilterPipe,
LoaderComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
ReactiveFormsModule,
SharedModule,
NgxMatSelectSearchModule,
FlexLayoutModule,
AddAutopointModule,
ArchiveModule,
ReservationsModule,
AvailabilityModule,
Ng2LoadingSpinnerModule.forRoot({}),
NavigationModule
],
providers: [
CommonService,
AlertService,
ListService,
LoaderService,
MenuService
],
bootstrap: [AppComponent]
})
首先加载这些组件是否正常,或者我做错了什么?