"react-app-polyfill"在IE11中不起作用 [英] "react-app-polyfill" doesn't work in IE11

查看:683
本文介绍了"react-app-polyfill"在IE11中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的React App无法在IE 11上运行.
我的客户希望该应用至少可以在ie11上运行.
所以,我必须解决这个错误.

My React App is not working on IE 11.
My client wants the app to work on at least ie11.
So, i have to solve this error.

我尝试了来自"react-app-polyfill"的官方文档.但这仍然行不通.
请帮我.

I tried the official documentation from "react-app-polyfill". But it still doesn't work.
Please help me.

src/index.jsx

import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Provider } from 'react-redux';
import store from './store';

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
);

serviceWorker.unregister();

package.json

  "dependencies": {
    ...
    "@types/jest": "^24.0.25",
    "@types/node": "^12.12.24",
    "@types/react": "^16.9.17",
    "@types/react-dom": "^16.9.4",
    "@types/react-redux": "^7.1.5",
    "@types/react-router-dom": "^5.1.3",
    "axios": "^0.19.0",
    "install": "^0.13.0",
    "node-sass": "^4.13.0",
    "npm": "^6.13.4",
    "react": "^16.12.0",
    "react-app-polyfill": "^1.0.5",
    "react-dom": "^16.12.0",
    "react-hotkeys": "^2.0.0",
    "react-redux": "^7.1.3",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "typescript": "^3.7.4"
  },
...
  "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"
    ]
  }

推荐答案

也许问题与react-scripts version有关,您正在使用3.3.0及更高版本的react-scripts.您可以检查package.json文件以进行验证.

Perhaps the issue is related to the react-scripts version, you are using react-scripts 3.3.0 and higher. You could check the package.json file to verify it.

GitHub中有一些线程报告此错误,您可以参考它们,例如: github.com/facebook/create-react-app/issues/8195 .

There are some thread reports this error in GitHub, you could refer to them, for example: github.com/facebook/create-react-app/issues/8197, github.com/facebook/create-react-app/issues/8195.

作为一种解决方法,您可以尝试降级react-scripts版本.据我所知,它仍然可以与react-scripts@3.2.0一起使用.

As a workaround, you could try to downgrade the react-scripts version. As far as I know, it can still work with react-scripts@3.2.0.

这篇关于"react-app-polyfill"在IE11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆