微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何防止从Angles的Routes数组加载路径时出现延迟

如何解决如何防止从Angles的Routes数组加载路径时出现延迟

我实现了延迟加载。分为模块。并设置路线。一切正常。

我对模块加载的顺序有疑问。我注意到,如果我尝试将任何模块加载到路由列表中,它将首先加载其上方的所有模块。

例如:如果我尝试加载ActionModule,则它将在执行之前加载其上方的所有模块(或经过其上方的所有路径),这会导致延迟。

我可以通过某种方式更改路由,使其仅加载所需的模块吗?

这是我的 routing.ts

browser network tab显示了我的问题。

//routing.ts(in text format)
export const routes: Routes = [
    { path: '',loadChildren: './pages/login/login.module#LoginModule' },{
    path: '',component: PagesComponent,children: [
 
        { path: 'blank',component: BlankComponent,data: { breadcrumb: '' },canActivate: [AuthGuard] },{ path: 'dashboard',component: DashBoardComponent,{ path: 'iframedashboard',component: iframeDashBoardComponent,data: { breadcrumb: 'Iframe Dashboard' },{ path: '',loadChildren: './pages/operations2/order-maintenance/order.module#OrderModule'},loadChildren: './pages/administration/administration.module#AdministrationModule'},loadChildren: './pages/base/base.module#BaseModule'},loadChildren: './pages/cms/cms.module#CMSModule'},loadChildren: './pages/operations/operation.module#OperationModule'},loadChildren: './pages/system-setup/system-setup.module#SystemSetupModule'},loadChildren: './pages/operations2/ordertemplate/order-template.module#OrderTemplateModule'},loadChildren: './pages/operations2/upload-file/upload-file.module#UploadFileModule'},loadChildren: './pages/operations2/order-trace/order-trace.module#OrderTraceModule'},loadChildren: './pages/system-setup2/action/action.module#ActionModule'},// 
        { path: '',loadChildren: './pages/system-setup2/rule-groups-maintenances/rule-group.module#RuleGroupModule'},loadChildren: './pages/system-setup2/rule/rule.module#RuleModule'},loadChildren: './pages/system-setup2/workcellType/work-cell-type.module#WorkCellTypeModule'},loadChildren: './pages/system-setup2/channel-maintenance/channel-maintenance.module#ChannelMaintenanceModule'},loadChildren: './pages/system-setup2/shift-calendar/shift-calendar.module#ShiftCalendarModule'},loadChildren: './pages/system-setup3/system-setup3.module#SystemSetup3Module'}

    ]
},{ path: 'error',component: ErrorComponent,data: { breadcrumb: 'Error' } },{ path: '**',component: NotFoundComponent }
];

export const routing: ModuleWithProviders = RouterModule.forRoot(routes,{
    // preloadingStrategy: PreloadAllModules,// <- comment this line for activate lazy load
    // useHash: true
});

谢谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。