ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.

 时间:2021年5月8日14:22:35

ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.. Find more at https://angular.io/errors/NG0100
    at throwErrorIfNoChangesMode (core.js:6792)
    at bindingUpdated (core.js:12940)
    at Module.ɵɵproperty (core.js:14740)
    at InvoiceManagementComponent_Template (invoice-management.component.html:55)
    at executeTemplate (core.js:9600)
    at refreshView (core.js:9466)
    at refreshComponent (core.js:10637)
    at refreshChildComponents (core.js:9263)
    at refreshView (core.js:9516)
    at refreshEmbeddedViews (core.js:10591)

问题的意思就是,页面一渲染好啦,别改啦,再改就给你报错啊。然后就这样了。

解决方法:在ngAfterViewInit()方法中添加一行代码即可

  ngAfterViewInit(): void {
    this.changeDetectorRef.detectChanges();
  }

这个只要在构造方法中声明一下即可

  constructor(
    public changeDetectorRef: ChangeDetectorRef
  ) { }

 

你可能感兴趣的:(记录,angular)