[英]Getting “Headers is undefined” in IE11
我有一个在所有浏览器中都能按预期工作的反应应用程序,除了 IE11。 在控制台中我可以看到这个错误:
它指向这行代码:
import {EventEmitter} from 'events';
**const headers = new Headers();**
headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');
class ApiService extends EventEmitter {
我已经到达这些职位,但我不清楚我应该做什么样的改变。 我应该只安装缺少的 pollyfills 还是需要更改代码语法...
https://www.codeproject.com/Questions/1275068/Javascript-fetch-not-working-in-internet-explorer
安装两者后:
window.fetch # https://github.com/github/fetch#read-this-first ,
promise # https://github.com/taylorhakes/promise-polyfill
现在我得到:
Object 不支持属性或方法“值”
我使用了 react-carbon-components 的 DataTable object,似乎也不支持它:
_defineProperty(DataTable, "translationKeys", Object.values(translationKeys));
导出 { 默认数据表 };
Internet Explorer 不支持 Fetch API 的 Headers 接口。
参考:
要使其与 IE 浏览器一起使用,您需要使用 polyfill。 您可以参考以下任何一种 polyfill 可以帮助您解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.