在 ng serve 和更新后,Angular 4 CLI 太慢 [英] Angular 4 CLI too slow after ng serve and when updating

查看:32
本文介绍了在 ng serve 和更新后,Angular 4 CLI 太慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行 ng serve 后粘贴了屏幕截图.它是 34946 毫秒.它非常缓慢,并且正在损害我们团队的表现.当我们也更新我们的代码时,重新加载页面需要很长时间.

I have pasted a screenshot after i run ng serve. it is on 34946 ms. it is pretty slow and it is hurting the performance of our team. When we also update our code, it takes too long to reload the page.

我的 angular 版本是 Angular CLI 版本 (1.2.7)

My version of angular is Angular CLI version (1.2.7)

这是 Angular CLI 中的问题还是正常现象?

Is this an issue or is this normal in Angular CLI?

我们的项目已经有大约 40 个组件,但我不确定它是否会影响加载性能.

We already have around 40 components on the project but i am not sure if it affects the loading performance.

这是我电脑的规格,以防万一.

Here is the specs of my PC just incase.

推荐答案

我解决了我的问题.发生的事情是我们的组件和其他资源都导入到 app.module.ts 中.因此,每次页面加载时,页面都会加载所有资源.我的解决方案是应用延迟加载来仅加载那些特定于我正在访问的路由的资源,它确实解决了加载问题.

i solved my problem. What happened is that our components and other resources are all imported in app.module.ts. Because of this, the page loads all the resources every time the page loads. My solution was to apply Lazy Loading to load only those resources that are specific to the routes that i am accessing and it did fix up the loading issue.

这篇关于在 ng serve 和更新后,Angular 4 CLI 太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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