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

查看:144
本文介绍了ng服务后和更新时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.

以下是我PC的规格,以防万一.

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服务后和更新时Angular 4 CLI太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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