简体   繁体   English

Angular 6-检查表达式后,生成模式已更改

[英]Angular 6 - Expression has changed after it was checked, build modes

I am getting below error in some components when build is done for debug mode, which is ng build . 在调试模式下完成构建时,某些组件出现错误,即ng build But as soon as I change build mode to prod using ng build --prod , these errors goes away. 但是,一旦我使用ng build --prod将构建模式更改为prod,这些错误就会消失。

I am unclear why this is happening. 我不清楚为什么会这样。

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked 错误: ExpressionChangedAfterItHasBeenCheckedError:检查表达式后,表达式已更改

Thanks 谢谢

Yes, this error does not appear in prod mode but appears on dev build. 是的,此错误不会在prod模式下显示,但会在dev版本上显示。 That is the warning/error which says that your input variables are modified before the change detection has completed. 这是warning/error ,它表示更改检测完成之前已修改您的输入变量。

In Dev mode, change detection triggers two times for every @Input change, so if any of the variable being updated in child components change in between, then you will get this error. 在开发模式下,每次@Input更改都会触发两次更改检测,因此,如果子组件中正在更新的任何变量在@Input更改之间都@Input更改,则将收到此错误。

In prod mode, change detection triggers only once, so it wont recognize that input was changed during change detection. 在生产模式下,更改检测仅触发一次,因此它不会识别输入在更改检测期间已更改。

Read more about this error here and how you can avoid it. 在此处详细了解此错误以及如何避免该错误。

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

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