首页 > 解决方案 > 如何在 Internet Explorer 10 或更高版本中使用 Create-React-App

问题描述

我正在使用 create-react-app 为公司 Intranet 开发代码。它是一个基于微软的系统,所以使用 IE 是必不可少的。不幸的是,我尝试过的任何东西都无法让我在 Internet Exploder 中加载它。

这是我的 package.json 文件。让我知道是否需要其他文件。不幸的是,我对 Babel 和 webpack 并不熟悉,所以我需要我能得到的所有帮助。

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.4.1",
    "bootstrap-social": "^5.1.1",
    "font-awesome": "^4.7.0",
    "http-proxy-middleware": "^0.20.0",
    "jquery": "^3.4.1",
    "popper": "^1.0.1",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-bootstrap": "^1.0.0-beta.16",
    "react-dom": "^16.12.0",
    "react-nested-menu": "^1.0.9",
    "react-popper": "^1.3.7",
    "react-redux": "^7.1.3",
    "react-redux-form": "^1.16.14",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "reactstrap": "^8.2.0",
    "redux": "^4.0.4",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build && xcopy /E /Q /H /Y build c:\\inetpub\\ReactFrontEnd",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "ie 11",
      "ie 10"
    ]
  },
  "proxy": "http://localhost:81/",
  "devDependencies": {
    "@babel/polyfill": "^7.8.3",
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.8.4",
    "@babel/preset-env": "^7.8.4",
    "@babel/preset-react": "^7.8.3"
  }
}

谢谢你。

标签: internet-explorerwebpackbabeljscreate-react-app

解决方案


我尝试搜索这个问题,发现最近"react-scripts": "3.3.0"出现了一些问题,因为这个项目不适用于 IE 浏览器。

我建议你尝试使用"react-scripts": "3.2.0"。它可以帮助解决这个问题。

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

参考:

  1. 尽管有 polyfills 和浏览器列表,但默认的 create-react-app 在 IE 中不起作用

  2. “react-app-polyfill”在 IE11 中不起作用

  3. IE11 支持在开发模式下不起作用,即使在添加所有 polyfill 并启用 ie11 支持后也是如此 #8197

  4. 为什么使用 create-react-app 创建的应用程序无法在 IE 浏览器中运行?#8195


推荐阅读