javascript - Why does Edge not accept `undefined` in class instantiation but Chrome does? How do I fix?
问题描述
Who is right? Chrome or Edge and how do I fix it? Do I need to change the webpack configuration to make it compensate for this issue?
See screenshots below - undefined
is being passed to new Headers()
Chrome doesn't care but Edge throws error invalid argument
and crashes entire app
解决方案
因为 IE(Edge 只是装扮 IE,让我们面对现实吧)是我们所有存在的祸根。
只要确保您传递的对象不是未定义的。您可以使用 javascripts truthy-ness 轻松做到这一点。
else {
return new Headers(headers || {});
}
看起来这是来自 Apollo-Link-Rest。只需像这样创建您的 RestLink
const restLink = new RestLink({
uri: 'https://swapi.co/api/',
headers: {},
});
推荐阅读
- java - Java 10 JavaFX java.lang.IllegalAccessError
- html - 将页脚保持在底部,但不固定
- mysql - 如何从查询中选择最后一个值?
- javascript - 如何仅在 Swiper JS 中为中间幻灯片启用中心幻灯片?
- python - AttributeError:“NoneType”对象没有“形状”属性/从多个轮廓框转换为单数
- python - 使用 Pandas 提取包含特定字符的数据
- unix - 格罗夫图像在同一行?
- ckeditor - CKEditor 5 更改事件并不总是触发
- mysql - SQL UPDATE boolean 从 db 中选择数字的最小值 WHERE boolean=false
- selenium - 想拿到
- 带有硒的xpath元素,但得到消息:元素不可交互