0
我用dotnet cli工具來創建一個新的角度應用程序,一切看起來和工作正常。如何使用angular2和aspnet核心解決類型錯誤?
C:/..myprojectlocation> dotnet new angular
這創建了一個新的文件夾和文件結構與角應用程序。在此之後,我將轉到home.component並從角度導入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
這感覺就像一個相當微不足道的一段代碼,但我一遍遍遇到類似的問題,我試着與其他模塊的接口。我可以在谷歌上看到類似的問題,似乎沒有太多方向,或者如何解決這些問題。
可能與HotModuleReplacement,Weback2,angular/universal或typescript版本有關。但是,我真的沒有很多線索,所以我一直堅持到我理解這個問題。
有人買這個人喝!所以,這似乎解決了我的痛苦。只希望我早點發現了這一點。 – jwize