如何使角4/6的加载速度更快? [英] how to make angular 4/6 faster in loading?

查看:84
本文介绍了如何使角4/6的加载速度更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 6 中,我创建了惰性模块,并且在路由时需要花费很多时间来加载.

In Angular 6, I have created lazy module and it takes a-lot time to load while routing.

有什么方法可以在角度6 中创建更快的Web应用程序吗?

Is there any way to create faster web application in angular 6 ?

推荐答案

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

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
})

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

这篇关于如何使角4/6的加载速度更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆