ERROR TypeError: jit_nodeValue_2(...).grElementList is not a function

ERROR TypeError: jit_nodeValue_2(...).grElementList is not a function

当我调整 window 大小时。下面的事件没有检测到 window resize 而不是我每次都得到的这个错误

@HostListener('window:resize', ['$event'])
  onResize(event) {
  this.innerWidth = window.innerWidth;
}

错误:

GuidanceReportComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: jit_nodeValue_2(...).grElementList is not a function
        at Object.eval [as handleEvent] (GuidanceReportComponent_Host.ngfactory.js? [sm]:1)
        at handleEvent (core.js:23107)
        at callWithDebugContext (core.js:24177)
        at Object.debugHandleEvent [as handleEvent] (core.js:23904)
        at dispatchEvent (core.js:20556)
        at core.js:21003
        at platform-browser.js:993
        at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
        at Object.onInvokeTask (core.js:17290)
        at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)

通过使用 Host Listener 装饰器,您指定 Angular 来侦听作为参数传递的 window 调整大小事件 ($事件)。 当您编写事件处理程序 onResize(event) 时,您实际上传递了 angular 记录的事件。因此,代码会向您抛出错误。下面的代码应该运行良好。

@HostListener('window:resize', ['$event'])
  onResize(event)
  {
    this.innerWidth = event.target.innerWidth;
  }