为什么 React 应用程序无法在 Internet Explorer 浏览器中运行

Why React app is not working in Internet Explorer browser

React App 根本无法在 Internet Explorer 中运行,我已针对此问题使用了多种解决方案,但没有找到任何解决方案。

  1. npm i react-app-polyfill --save
  2. 在index.js

    中添加以下文件

    进口'react-app-polyfill/ie9'; 导入 'react-app-polyfill/ie11'; 导入 'react-app-polyfill/stable';

  3. 在 package.json 中并将 "ie 11" 添加到 "browserslist->development" 部分:

*

"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"ie 11",
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
  1. 删除 node_modules
  2. 中的 .cache
  3. npm 启动

提前致谢

请打开 package.json 文件并检查您是否使用 "react-scripts": "3.3.0" 或更高版本?

我看到现在很多用户都有类似的问题。

如果您使用 "react-scripts": "3.3.0" 或更高版本,请尝试使用 "react-scripts": "3.2. 0。它可以帮助解决这个问题。

进行此更改后尝试清除 node_modules/.cache。

参考文献:

  1. IE11 support doesn't work in dev mode, even after adding all polyfills and enabling ie11 support #8197

  2. Why application created using create-react-app is not working in IE browser? #8195