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

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

问题描述

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

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

推荐答案

在开发模式下,更改检测会在第一次运行后立即执行第二次运行,如果任何绑定值在第一次和第二次运行之间发生更改,则会产生错误.这有助于定位检查值有副作用或字段或函数在后续调用中不返回相同值的错误,这会破坏 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 sanitizer 服务从 [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天全站免登陆