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

我的React App无法在IE 11上运行。

我的客户希望该应用至少在ie11上运行。

所以,我必须解决这个错误。

我尝试了来自“ react-app-polyfill”的官方文档。但这仍然行不通。

请帮我。

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();

  "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文件进行验证。

有一些线程报告这个错误在GitHub上,你可以参考它们,例如:github.com/facebook/create-react-

app/issues/8197,github.com/facebook/create-react-

app/issues/8195。

解决方法是,您可以尝试降级react-scripts版本。据我所知,它仍然可以使用react-scripts@3.2.0

以上是 “ react-app-polyfill”在IE11中不起作用 的全部内容, 来源链接: utcz.com/qa/430061.html

回到顶部