单击关闭Angular 5中的Angular2-通知时单击ViewDestroyedError

问题描述 投票:6回答:1

单击关闭通知时出现此错误。它似乎是随机发生的。

zone.js:196未捕获的错误:ViewDestroyedError:尝试使用销毁的视图:detectChanges在viewDestroyedError(core.js:9540)在Object.debugUpdateDirectives [作为updateDirectives](core.js:14336)在checkAndUpdateView(core.js:13508)在callWithDebugContext(core.js:14740)在Object.debugCheckAndUpdateView [作为checkAndUpdateView](core.js:14277)在ViewRef_.webpackJsonp ../ node_modules/@angular/core/esm5/core.js.ViewRef_.detectChanges(core.js:11300)在angular2-notifications.umd.js:531在ZoneDelegate.webpackJsonp ../ node_modules / zone.js / dist / zone.js.ZoneDelegate.invoke(zone.js:392)在Object.onInvoke(core.js:4629)在ZoneDelegate.webpackJsonp ../ node_modules / zone.js / dist / zone.js.ZoneDelegate.invoke(zone.js:391)

此错误在我的应用程序中多次击中(appx 1667次),因为它执行更改检测生命周期挂钩。

[如果有人有解决此问题的想法,请帮助我解决这个问题。

Angular2-Notification

angular angular5
1个回答
0
投票

您可以尝试以下方法:

if (!this.changeDetectorRef['destroyed']) {
     this.changeDetectorRef.detectChanges();
}
© www.soinside.com 2019 - 2024. All rights reserved.