vue-cli3 打包IE11报错

coolicer
  • 71

babel.config.js

module.exports = {
  presets: [
    [
      "@vue/app",
      {
        useBuiltIns: "entry",
      }
    ]
  ]
}

main.js

import '@babel/polyfill'

package.json

"browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 10"
  ],

以上配置,在IE11下还是报错。没有把class转,为什么polyfill没有生效?
图片描述

项目使用的第三方库

    "axios": "^0.18.0",
    "jsonp": "^0.2.1",
    "swiper": "^4.4.6",
    "video.js": "^7.4.1",
    "videojs": "^1.0.0",
    "vue": "^2.5.22",
    "vuex": "^3.0.1"
回复
阅读 2k
2 个回答
✓ 已被采纳

polyfill作用不是给你转class的,你的babel没有配置好,vue-cli3初始化项目的时候不知道你咋操作的,下面是我的.babelrc

{
  "presets": [
    [
      "env",
      {
        "modules": false,
        "targets": {
          "browsers": [
            "> 1%",
            "last 2 versions",
            "not ie <= 8"
          ]
        }
      }
    ],
    "stage-0"
  ],
  "plugins": [
    "transform-vue-jsx",
    "transform-runtime"
  ],
  "env": {
    "test": {
      "presets": [
        "env",
        "stage-2"
      ],
      "plugins": [
        "transform-vue-jsx",
        "transform-es2015-modules-commonjs",
        "dynamic-import-node"
      ]
    }
  }
}

已解决。swiper导致,我在vue.config.js加了对swiper的处理,没有生效。导致我一直在找问题。

你知道吗?

宣传栏