无论哪种情况:
document.getElementById('body');
// or
window.document.getElementById('body');
我懂了 error TS2304: Cannot find name 'window'.
我是否缺少tsconfig.json
应安装的定义文件?
我在跑步tsc
和跑步时收到消息vscode
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "ES2016",
"typeRoots": [
"node_modules/@types/",
"typings/index.d.ts"
]
},
"exclude": [
"node_modules",
"**/*-aot.ts"
]
}
我的答案:与tsconfig.json
我针对es5
并使用lib: ["es2015", "dom"]
tsc
?您当前的tsconfig.json
文件是什么?如果需要帮助,您需要提供更多相关信息