angular7 - 如何防止延迟从 Routes 数组以角度加载路径
问题描述
我已经实现了延迟加载。分为模块。并设置路线。一切正常。
我对模块加载的顺序有疑问。我注意到,如果我尝试在路由列表中加载任何模块,它会首先加载它上面的所有模块。
例如:如果我尝试加载 ActionModule,那么它会加载它上面的所有模块(或通过它上面的所有路由),然后再开始操作,这会导致延迟。
我可以以某种方式更改路线,使其仅加载所需的模块吗?
这是我的 routing.ts
和 浏览器网络选项卡显示我的问题。
//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, data: { breadcrumb: '' }, canActivate: [AuthGuard] },
{ path: 'iframedashboard', component: iframeDashBoardComponent, data: { breadcrumb: 'Iframe Dashboard' }, canActivate: [AuthGuard] },
{ path: '', loadChildren: './pages/operations2/order-maintenance/order.module#OrderModule'},
{ path: '', loadChildren: './pages/administration/administration.module#AdministrationModule'},
{ path: '', loadChildren: './pages/base/base.module#BaseModule'},
{ path: '', loadChildren: './pages/cms/cms.module#CMSModule'},
{ path: '', loadChildren: './pages/operations/operation.module#OperationModule'},
{ path: '', loadChildren: './pages/system-setup/system-setup.module#SystemSetupModule'},
{ path: '', loadChildren: './pages/operations2/ordertemplate/order-template.module#OrderTemplateModule'},
{ path: '', loadChildren: './pages/operations2/upload-file/upload-file.module#UploadFileModule'},
{ path: '', loadChildren: './pages/operations2/order-trace/order-trace.module#OrderTraceModule'},
{ path: '', loadChildren: './pages/system-setup2/action/action.module#ActionModule'},//
{ path: '', loadChildren: './pages/system-setup2/rule-groups-maintenances/rule-group.module#RuleGroupModule'},
{ path: '', loadChildren: './pages/system-setup2/rule/rule.module#RuleModule'},
{ path: '', loadChildren: './pages/system-setup2/workcellType/work-cell-type.module#WorkCellTypeModule'},
{ path: '', loadChildren: './pages/system-setup2/channel-maintenance/channel-maintenance.module#ChannelMaintenanceModule'},
{ path: '', loadChildren: './pages/system-setup2/shift-calendar/shift-calendar.module#ShiftCalendarModule'},
{ path: '', 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
});
提前致谢。
解决方案
因此,虽然我不确定浏览器网络选项卡的含义:
是否在正确模块之前加载所有模块
或者
它只是搜索所有先前的路线,以到达正确的模块路线*
我们永远不会知道:无论如何我通过添加加载微调器/指示器解决了这个问题:)
*为更好地理解而编辑(语法/英语)
改变了
是否只是搜索所有先前的模块,以找到正确的模块
至
是否只是搜索所有先前的路线,以到达正确的模块路线
推荐阅读
- c# - 如何修复错误“请求过滤模块配置为拒绝查询字符串过长的请求”
- r - 在带有正则表达式的 data.table 中使用 %in%
- watchos - WatchOS 6.2.6 - 无法使用独立应用测试 sanbox 应用内购买
- branch - 有人使用anylogic 与Branch 合作吗?
- flutter - 颤振:如何制作自定义颤振容器?
- javascript - 我无法使用 Id 选择元素?
- javascript - 水平折叠仅扩展 1 个元素而不是所有元素
- reactjs - 'isValid' 总是假的
- javascript - 没有登录Angular的用户交互?
- javascript - 如何在多个输入标签html中添加更多图像?