如何使React应用程序由Create-React-App支持IE11创建

发布于 2025-01-21 10:40:54 字数 449 浏览 1 评论 0原文

我有一个由最新版本的Create-React-App创建的简单React应用程序(仅支持节点版本14+)。我正在尝试使此应用程序在IE11中运行。因此,我确实以下是以下内容:

  • 安装了react-app-polyfill
  • 在index.js的开头添加了两个导入:导入“ react-app-polyfill/ie11”,导入“ react” react-app-polyfill/stable/stable“
  • 添加” IE 11 “在软件包中的开发下。JSON

我安装了一个Chrome扩展名,即IE选项卡,并在此处进行了测试。但是仍然不起作用,我会在打开Chrome DevTool时看到以下错误: IE:错误:对象不支持属性或方法“ Endswith”。资料来源:http:// localhost:3000/static/js/bundle.js:63700

有人可以帮忙吗?

I have a simple react app created by the latest version of create-react-app (that only support node version 14+). I am trying to make this app run in IE11. So as recommended, I did following:

  • installed react-app-polyfill
  • added two imports at the beginning of index.js: import "react-app-polyfill/ie11", import "react-app-polyfill/stable"
  • added "ie 11" under the development in the package.json

I installed a chrome extension, IE Tab, and tested there. But still not working, I see following error when I open the chrome devtool:
IE: Error: Object doesn't support property or method 'endsWith'. Source: http://localhost:3000/static/js/bundle.js:63700

Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初见 2025-01-28 10:40:54

我可以复制这个问题。您可以添加a 对于endswith(),以便它可以在IE 11中运行良好。

您可以在< script>标签中包含polyfill in index.html

I can reproduce the issue. You can add a polyfill for endsWith() so that it can work well in IE 11.

You can include the polyfill within <script> tag in index.html.

enter image description here

千紇 2025-01-28 10:40:54

在Google的第三页上找到了该解决方案。它将为您提供帮助:

  • 您要做的第一件事 - 在您的应用程序的顶部包括react-app-polyfill中的polyfills

  • 然后在包装中。 P>
  • 最后 - 在您的public/index.html中添加元标记

Found this solution on the 3rd page of google. It's going to help you:

  • The first thing you have to do - include polyfills from react-app-polyfill at the top of your app

  • Then in package.json set up browserlist (add ie11, ie10, etc)

  • In the end - add meta tag in your public/index.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文