繁体   English   中英

IE11中的Angular FormData forEach和getAll错误方法

[英]Angular FormData forEach and getAll error method in IE11

在 Angular 中,我尝试循环 FormData object 并且此错误显示在 IE11 中。 顺便说一句,一切都在 Chrome 中工作。

const formData = new FormData();
// appended file here
formData.forEach((x: File) => {
  console.log(x);
});

IE11: "ERROR TypeError: Object doesn't support property or method 'forEach'"

IE11: "ERROR TypeError: Object doesn't support property or method 'getAll'"

有没有办法在 IE11 中正确循环这个? 为什么 IE11 显示此错误,而其他浏览器则没有? 谢谢!

浏览器以不同的速度实现新的 JS 特性,而 IE 总是落后。 现在,特别是 Microsoft 宣布不会为 IE 浏览器提供新的更新,您将始终在尝试支持 IE 版本时受苦。 通过这种方式在您的 angular 项目中使用 IE 11,您需要设置更新一些配置以提供对它们的支持。

tsconfig.json将目标设置为 es5:

"compilerOptions": {
    "target": "es5"
}

broswerlist文件中将not IE 11的行更改为IE 11

如果需要支持更多功能,您需要在polyfills.ts中导入 polyfill 以使您的项目正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM