Angular2中的生产和开发模式有什么区别? [英] What is the difference between production and development mode in Angular2?

查看:319
本文介绍了Angular2中的生产和开发模式有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我必须在生产模式下运行我的应用程序.这些模式有什么区别?

For some reason, I have to run my app in production mode. What is the difference between those modes?

推荐答案

在开发模式下,更改检测会在第一次运行后立即进行第二次运行,并且如果第一次和第二次运行之间的绑定值发生更改,则会产生错误.这有助于查找在检查值具有副作用或字段或函数在后续调用中未返回相同值的bug,这会破坏Angular的更改检测.

In development mode, change detection does a second run immediately after the first run and produces an error if any bound value has changed between the first and the second run. This helps to locate bugs where checking values has side-effects or fields or functions don't return the same value on subsequent calls which undermines Angular's change detection.

在开发模式下,在第二次更改检测运行期间,Angular还会进行一些深度对象比较,而在生产过程中不会进行深度对象比较,以检测出不允许的模型更改.

In development mode, during the second change detection run, Angular also does some deep object comparisons that it won't do in production to detect model changes that are disallowed.

更新:

在开发模式下,当HTML清理程序服务从绑定[innerHTML]="..."[ngStyle]="..."中剥离值时,也会向控制台打印提示. 另请参见:在RC中. 1有些样式无法使用绑定语法添加

In development mode, a hint is also printed to the console when the HTML sanitizer service strips values from bindings [innerHTML]="..." or [ngStyle]="...". See also: In RC.1 some styles can't be added using binding syntax

这篇关于Angular2中的生产和开发模式有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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