【发布时间】:2017-10-30 09:56:30
【问题描述】:
我使用 dotnet cli 工具创建了一个新的 Angular 应用程序,一切看起来都很好。
C:/..myprojectlocation> dotnet new angular
这将使用 Angular 应用程序创建一个新的文件夹和文件结构。在此之后,我转到 home.component 并从 angular 导入 AfterViewInit 事件。
import { Component, AfterViewInit } from '@angular/core';
同样,我添加了事件处理程序:
ngAfterViewInit(): void {
const inputs: NodeListOf<HTMLInputElement> =
document.getElementsByTagName("input");
}
当我构建我的项目时,它超出了但是当我刷新我的页面时,我在运行时收到以下错误。
An unhandled exception occurred while processing the request.
Exception: Call to Node module failed with error: Error: Uncaught (in
promise): ReferenceError: document is not defined
ReferenceError: document is not defined
这感觉像是一段相当微不足道的代码,但是当我尝试与其他模块交互时,我一遍又一遍地遇到类似的问题。我可以在 google 上找到看似相似的问题,但似乎没有太多的方向或如何解决它们。
可能与 HotModuleReplacement、Weback2、angular/universal 或 typescript 版本有关。但是,老实说,我没有太多线索,所以在我理解这个问题之前,我被困住了。
【问题讨论】:
标签: angular asp.net-core typeerror webpack-2