javascript - 在 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 ,
承诺 # https://github.com/taylorhakes/promise-polyfill
现在我得到:
对象不支持属性或方法“值”
我使用了 react-carbon-components 的 DataTable 对象,似乎也不支持它:
_defineProperty(DataTable, "translationKeys", Object.values(translationKeys));
导出 { 默认数据表 };
解决方案
Internet Explorer 不支持 Fetch API 的 Headers 接口。
参考:
要使其与 IE 浏览器一起使用,您需要使用 polyfill。您可以参考以下任何一种 polyfill 可以帮助您解决问题。
推荐阅读
- sveltekit - 在 SvelteKit 中使用 JWT 进行服务器端授权
- reactjs - 如何获取承诺的“数据”属性值
- python - ModuleNotFoundError:没有名为“json_minify”的模块
- docker - 如何为 Puckel/docker-airflow 创建/启用密码登录
- javascript - 反应:无效的 JSON
- concordion - Concordion:自动将 Markdown 链接转换为 HTML 链接?
- jquery - 防止对子 div 鼠标悬停的操作
- android - IndoorAtlas (FreeVersion),将节点放置在 AR 中的给定平面图 POI/Waypoints - Android ARCore
- excel - 在 Excel 中的所有行中的两列之间求和 yearfrac
- python - 如何从类中的子目录加载方法并使用类中的字段