【问题标题】:'Proxy' is undefined in IE“代理”在 IE 中未定义
【发布时间】:2020-06-06 11:27:04
【问题描述】:

我已经通过 React+Node+Umi 构建了一个 Excel 插件。我们已经实施了我们的身份验证系统。身份验证在 Chrome 和 Safari 中有效,我刚刚意识到它在 IE11 中效果不佳; F12 表示'Proxy' is undefined

虽然它是一个 Excel 插件,但我们可以在浏览器中重现错误(以及相同的错误消息)。在 IE 11 中打开链接 https://jsaddin.10studio.tech/welcome/?next=formulaEditor,使用 ID 3094557608@qq.com 和密码:123456 登录。我们可以在 F12 中看到错误消息。

有谁知道

  1. 如何解决这个问题?
  2. 我怎么知道我的代码的哪个库/部分使用了这个Proxy?我可以用替代品代替它。

编辑1:.umirc.ts

treeShaking: true,
targets: {
  ie: 9,
  safari: 9,
},

package.json:

"umi": "^2.7.0",
"umi-plugin-react": "^1.8.0",
"umi-types": "^0.2.0"

编辑 2:

我尝试了yarn add proxy-polyfill,然后是yarn start。奇怪的是,它在 localhost Invalid character'umi' is undefined 中引发了错误:

【问题讨论】:

  • 嗨,我也面临同样的问题,“代理”未定义。我添加了导入“@pnp/polyfill-ie11”;但仍然是同样的问题。请帮忙

标签: node.js reactjs express cross-browser umijs


【解决方案1】:

看起来你缺少一个 polyfill。你检查了 umi.js 的这个配置吗? https://umijs.org/config/#targets

将 ie 的目标设置为 11(如上面的链接)应该可以添加您需要的 polyfill。

  targets: {
    ie: 11,
    ...other browsers
  },
  ...rest of the config

乐:

如果 umi.js 出现问题,您可以尝试自己添加所需的 polyfill(例如,这里是 Proxy https://github.com/GoogleChrome/proxy-polyfill 的一个)

【讨论】:

  • 当前是ie: 9 in .umirc.ts。因为是Configuring the minimum version of browsers you want to compatible with,应该兼容IE 11吧?
  • @SoftTimur 似乎在 umi.js github.com/umijs/umi/issues/3985 的 Github 存储库中有一个未解决的问题。我建议自己添加 polyfill,直到问题解决
  • 哦,对不起,我不知道。您是否尝试自己添加所需的 polyfill?
  • 我还没试过。我仍在尝试在本地 Windows 上测试该项目。根据readme我应该先Install via your favourite package manager as proxy-polyfill,那么You should include proxy-polyfill into your build system (just require it directly, it doesn't export anything), or import the proxy.min.js file directly. 是什么意思?
  • 你可以在项目根目录的某个地方做require('proxy-polyfill')(你有一个 index.js 文件,你挂载 react 吗?),在安装包之后(你使用 npm 吗?)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-25
  • 1970-01-01
  • 1970-01-01
  • 2015-11-23
  • 2011-03-24
  • 2018-01-27
  • 1970-01-01
相关资源
最近更新 更多