【发布时间】:2020-12-03 17:40:50
【问题描述】:
伙计们,我有一个启用延迟加载的 Angular 应用程序,并且在模块下方。
CoreModule,(在应用模块中导入)
SharedModule,(在每个模块中导入)
项目模块,
授权模块
这是我的应用路由模块:
{ path: "", redirectTo: "auth/sign-in", pathMatch: "full" },
// { path: "auth", loadChildren: () => AuthModule }, // Bundled in main js file
{ path: "auth", loadChildren: () => import("@core/auth/auth.module").then(p => p.AuthModule) },
{ path: "projects", loadChildren: () => import("@projects/projects.module").then(p => p.ProjectsModule) }
在根应用程序路由模块中使用 动态导入 语法时,在浏览器中获取的 javascript 包如下:(刷新 /auth/sign-in)
- core-auth-auth-module.js
- default~core-auth-auth-module~projects-projects-module.js
- projects-projects-module.js(预加载)
1- 那么模块 1 和模块 2 到底是什么?
然后,当我在 loadchildren 上使用函数语法时,前 2 个模块不会在浏览器中加载。
2- 有什么区别?
【问题讨论】:
标签: angular lazy-loading angular-routing angular-lazyloading