vue与react兼容IE11

1.安装react-app-polyfill / @babel/polyfill与es6-promise
// react依赖包
npm install react-app-polyfill  --save
// vue依赖包
npm install @babel/polyfill --save
npm install es6-promise --save

2.需src/main.js (首行引入)
// react引入
import 'react-app-polyfill/ie11'  
import 'react-app-polyfill/stable'
// vue引入
import '@babel/polyfill'
import promiseIE from 'es6-promise'
promiseIE.polyfill()

3.需babel.config.js配置
module.exports = {
  presets: [
    // vue语法
    '@vue/cli-plugin-babel/preset',
    // react语法
    '@babel/preset-react',
  ],
}

4.需package.json中配置ie11
  "browerslist" {
    "production": [
      "> 1%",
      "not dead",
      "ie11"
    ],
     "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie11"
    ]
  },

5.需删除package-lock.json重新获取
  npm install

6.注意axios版本
 "axios" : "^0.21.1"

你可能感兴趣的:(react.js,前端,前端框架,vue.js,javascript)