Vue-cli3以上版本添加IE兼容

安裝babel相關(guān)依賴做js轉(zhuǎn)換處理
package.json

{
  ...
  "dependencies": {
    "@vue/cli-plugin-babel": "~4.4.0",
    "core-js": "^3.15.2",
    "regenerator-runtime": "^0.13.7",
  }
  ...
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 9"
  ]
}

配置babel
babel.config.js

module.exports = {
  presets: [
    ['@vue/app', {
      useBuiltIns: 'entry'
    }]
  ],
  plugins: [
    [
      'component',
      {
        libraryName: 'element-ui',
        styleLibraryName: 'theme-chalk'
      }
    ]
  ]
};

由于babel默認(rèn)不處理node-modules里面的文件,故需要將要處理的依賴手動添加到需要處理的列表中
vue.config.js

module.exports = {
  transpileDependencies: ['element-ui']
}

入口文件處添加babel
main.js

import 'core-js/stable';
import 'regenerator-runtime/runtime';

參考文檔:
vue-cli文檔之瀏覽器兼容性

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容