react页面兼容ie步骤

The React App is not compatible IE default.If open this app in IE,it will display a blank page.So, you must modify some files .
Step 1:
npm install --save es5-shim es5-shim/es5-sham console-polyfill fetch-ie8 babel-polyfill
Step 2:
Modify this apps entry file that called "index.js"

require('es5-shim');
require('es5-shim/es5-sham');
require('console-polyfill');
require('fetch-ie8');
require('babel-polyfill');
const React = require('react');
const ReactDOM = require('react-dom');
const App = require('./App').default;

ReactDOM.render(, document.getElementById('root'));

finally,the content of pakage.json file is:

{
"name": "XXX",
"version": "0.1.0",
"private": true,
"dependencies": {
"antd": "^2.12.7",
"axios": "^0.16.2",
"babel-polyfill": "^6.7.4",
"bootstrap": "^3.3.7",
"classnames": "^2.2.5",
"console-polyfill": "^0.2.2",
"es3ify-loader": "^0.2.0",
"es5-shim": "^4.4.1",
"eventsource-polyfill": "^0.9.6",
"fetch-ie8": "^1.4.0",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"script": "^0.1.4",
"webpack": "^3.10.0"
},
"devDependencies": {
"react-scripts": "1.0.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"description": "This project was bootstrapped with Create React App.",
"main": "index.js",
"author": "",
"license": "ISC"
}

猜你喜欢

转载自blog.csdn.net/weixin_41043580/article/details/88413746