当`enableProdMode()`会发生什么 [英] what exactly happens when `enableProdMode()`

查看:1544
本文介绍了当`enableProdMode()`会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TypeScript进行Angular2 quick start演示.一切正常,但演示完成后,我在浏览器控制台中看到一条消息

I'm working with Angular2 quick start demo using TypeScript. Everything is working fine with this but after completion of demo I have seen a message in my browser console

Angular 2在开发模式下运行.调用enableProdMode()以启用生产模式.

我已经在此答案.

import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { enableProdMode } from '@angular/core';

enableProdMode();
bootstrap(AppComponent);

问题

  1. 应用程序转为生产模式时会发生什么?
  2. 除了删除控制台消息外,我没有看到应用程序行为的任何变化?

有人可以解释吗?

推荐答案

启用生产模式不会禁用更改检测.此功能是Angular2将模板与关联类的状态进行同步的基础.

Enabling the production mode won't disable change detection. This feature is the foundation of Angular2 to synchronize the template with the state of the associated class.

在生产模式下,只执行一次而不是两次...

With production mode, only one run is done not two...

这篇关于当`enableProdMode()`会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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