The react project is compatible with ie
The configured react project runs OK in chrome, but an error is reported under ie.
Add a @babel/polyfill
npm install @babel/polyfill --save
It may also be necessary to introduce:
npm install --save core-js@3
And, introduce at the top of the enable file app.js:
import @babel/polyfill
My project doesn't work with the above method. used the next method.
VUE project reports error SCRIPT1002: syntax error in IE11 white screen
- Install react-app-polyfill and core-js
npm install react-app-polyfill core-js
- Introduce at the very top of the project src/index.js file
import 'core-js/es'
import 'react-app-polyfill/ie9'
import 'react-app-polyfill/stable'
- Modify package.json
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"ie > 9"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version",
"ie > 9"
]
},
"devDependencies": {
}
If it fails, delete node_modules and download again.
If the download fails, you can read another article:
https://blog.csdn.net/qq_42571665/article/details/121745609 .
The react project is compatible with ie and reports an error, map is undefined
According to the official react document, use core-js to introduce polyfill in index.js:
import 'react-app-polyfill/ie9'
import 'core-js/es6/map'
import 'core-js/es6/set'
This compatibility problem is solved by introducing es6-sham and es6-shim at the head of the index.html file to ensure that the polyfill script is executed before all codes are executed
...
<title>React App</title>
<script src="./es6-sham.js"></script>
<script src="./es6-shim.js"></script>
</head>
...