【问题标题】:Why React app is not working in Internet Explorer browser为什么 React 应用程序无法在 Internet Explorer 浏览器中运行
【发布时间】:2020-06-10 00:04:07
【问题描述】:

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 中的 .cache
  2. npm 开始

提前致谢

【问题讨论】:

    标签: reactjs internet-explorer webpack create-react-app polyfills


    【解决方案1】:

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

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

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

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

    参考资料:

    1. Default create-react-app does not work in IE despite polyfills and browser list

    2. “react-app-polyfill” doesn't work in IE11

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

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

    【讨论】:

    • 嗨 @deepak-MSFT 我正在使用 "react-scripts": "3.2.0" only ,仍然无法正常工作
    • 尝试创建一个新应用并尝试使用 "react-scripts": "3.2.0" 来检查该项目是否正在运行。这可能是您当前应用的缓存问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-03
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    相关资源
    最近更新 更多