且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使角4/6的加载速度更快?

更新时间:2023-02-07 07:46:54

如果在导航时加载模块花费太多时间,则可以考虑急于预加载模块.这样做是先加载主应用程序模块并显示视图,然后在后台加载所有其他模块,甚至在导航至其他模块之前.

If loading a module while navigating takes too much time, you could consider eagerly preloading modules instead. What this does is load your main application module first and display your view, and in the background load all the other modules even before you navigate to them.

您可以使用以下RouterModule配置来使其工作:

You can use the following RouterModule configuration to make that work:

RouterModule.forRoot(appRoutes, {
    preloadingStrategy: PreloadAllModules
})

您可以参考官方文档更多信息.