简体   繁体   English

angular2-Angular2是否在每个事件上更新视图?

[英]angular2 - Does Angular2 do a view update on every event?

Angular2 uses the concept of Zones to remove the need to manually do a view update. Angular2使用区域的概念消除了手动进行视图更新的需要。 That's all great but, when does Angular2 decide to do a view update ? 太好了,但是Angular2何时决定进行视图更新?

After reading this article I have got the notion that Angualar2 does a view update on almost every event. 阅读本文后,我想到了Angualar2几乎对每个事件都进行了视图更新。 Even on a mousemove event !! 即使发生mousemove事件! Is that true ? 真的吗 ?

Because if it is, its damn computationally expensive. 因为如果是这样,那么该死的计算量很大。

Depends on what you mean with an "event". 取决于您对“事件”的含义。 Angular doesn't update on events no event listeners are registered for from within Angular2. Angular不会针对未在Angular2中注册任何事件侦听器的事件进行更新。

Angular also doesn't update just because of an event, it just runs change detection to see if something needs updating. Angular也不会仅仅因为事件而更新,它只是运行更改检测以查看是否需要更新。

With ChangeDetectionStrategy and other measures you also can limit which parts of your application it runs change detection on. 使用ChangeDetectionStrategy和其他措施,您还可以限制运行更改检测的应用程序的哪个部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM