use*_*237 7 angular-material angular angular-reactive-forms
我该如何解决以下错误...有人可以帮我解决它吗?
\nERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for \'ng-valid\': \'false\'. Current value: \'true\'.. Find more at https://angular.io/errors/NG0100\n at throwErrorIfNoChangesMode (core.js:6757)\n at bindingUpdated (core.js:12967)\n at checkStylingProperty (core.js:16757)\n at \xc9\xb5\xc9\xb5classProp (core.js:16665)\n at NgControlStatusGroup_HostBindings (forms.js:1327)\n at processHostBindingOpCodes (core.js:9213)\n at refreshView (core.js:9491)\n at refreshComponent (core.js:10616)\n at refreshChildComponents (core.js:9242)\n at refreshView (core.js:9495)\nRun Code Online (Sandbox Code Playgroud)\n谢谢你!
\n查看您的调用堆栈,它看起来像 中的问题列表NgControlStatusGroup_HostBindings。
在这里找到了答案。6 分钟多的视频解释了如何查找错误根源。解说员接着说,这个问题通常是由于使用 ngAfterViewInit 而不是 ngOnInit 引起的。
这一更改对我有用,并导致了其他问题,但至少它提供了缩小问题范围并解决问题的能力。
最终深入了解后,HTML 模板中的对象正在读取 app.component.ts 中的一个布尔值,然后紧接其下方的对象调用了一个更改该值的方法。
通过单击 chrome 开发工具控制台中的 app.component.html 链接(上图中圈出的部分),我就找到了问题所在。通过将有问题的对象移至模板中的更高位置来解决此问题。
| 归档时间: |
|
| 查看次数: |
692 次 |
| 最近记录: |