微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我已经使用 create single-spa 创建了 single-spa 应用程序,并且它在除 IE11 之外的所有浏览器中都可以正常工作

如何解决我已经使用 create single-spa 创建了 single-spa 应用程序,并且它在除 IE11 之外的所有浏览器中都可以正常工作

IE11 error while running app

注意:我添加了 core.js 依赖,在 IE 中仍然报错

解决方法

您是否添加了以下脚本来使 IE 11 中的单 spa 工作?

<script>
  if (typeof fetch === 'undefined') {
    document.write('<script src="https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.js"><\/script>')
  }
  if (typeof String.prototype.startsWith === 'undefined' || typeof Promise === 'undefined') {
    document.write('<script src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.10.4/dist/polyfill.min.js"><\/script>')
  }
</script>

另外,single-spa使用的Webpack 5默认不支持IE11。要使其支持 IE11,您需要在 webpack.config.js 中指定 target: ['web','es5']

更多信息,您可以参考this similar thread。如果仍然无法在 IE11 中运行,则可以使用 this working sample。它在 IE11 和其他浏览器中运行良好。

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。