尝试使用时window.FormData
出现以下错误:
The name 'FormData' does not exist in the current scope
FileReader 也是如此
尝试使用时window.FormData
出现以下错误:
The name 'FormData' does not exist in the current scope
FileReader 也是如此
添加dom
到项目中的lib
数组中tsconfig.json
。
{
"compilerOptions": {
...
"lib": ["es2018", "dom"], // add `dom` to the array
...
}
}
您可以使用以下方法检查功能是否存在:
if (window.FormData) {
alert('Yes');
}
这依赖于虚假检查 - 如果您想明确,请使用。
if (typeof FormData !== 'undefined') {
alert('Yes');
}