[英]Typescirpt : XMLHttpRequest is not defined in .ts file
我有一個.ts文件,包含以下代碼:
var xhttp = new XMLHttpRequest();
當我運行grunt任務以使用Typescript構建ts文件時,沒有錯誤。 當我嘗試實例化類並用此行調用函數時,出現此錯誤:
ReferenceError:未在AssetFinder.Asset.req(C:** \\ asset-player \\ src \\)的HttpRequester.send(C:** \\ asset-player \\ src \\ assetlib \\ HttpRequester.js:9:25)中定義XMLHttpRequest。 Assetlib \\ Asset.js:41:21)。 (C:** \\ asset-player \\ index.js:21:20)位於Object.Module._extensions..js(module.js:404:10)的Module._compile(module.js:397:26)啟動時(node.js:139)的Function.Module.runMain(module.js:429:10)的Function.Module._load(module.js:300:12)的Module.load(module.js:343:32) :18)在node.js:999:3
您必須引用一個(最終)包含XMLHttpRequest
聲明的文件。
該聲明最終在這里: https : //github.com/Microsoft/TypeScript/blob/master/lib/lib.webworker.d.ts
您可能需要仔細檢查打字稿配置: https : //github.com/Microsoft/TypeScript
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.