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

I have created single-spa application using create single-spa and its working fine in all browser except IE11

IE11 error while running app

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

您是否添加了以下脚本来使 single-spa 在 IE 11 中工作?

<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. If you still can't make it work in IE11, you can use this working sample。它在IE11和其他浏览器中运行良好。