如何使React应用程序由Create-React-App支持IE11创建
我有一个由最新版本的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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以复制这个问题。您可以添加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.在Google的第三页上找到了该解决方案。它将为您提供帮助:
您要做的第一件事 - 在您的应用程序的顶部包括
react-app-polyfill
中的polyfills最后 - 在您的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 appThen in package.json set up browserlist (add ie11, ie10, etc)
In the end - add meta tag in your public/index.html