Vue CLI 3 + Vuetify - 不适用于 IE 11(Babel 不转译?)

NGA*_*YEN 5 babeljs babel-polyfill vuetify.js vue-cli-3

我在我的项目中使用 Vue CLI 3 和 Vuetify。它在 Chrome 和 iOS 12 上运行良好,但在 IE11 和 iOS Safari < 12 上显示空白页面。 IE11 中的控制台显示:SCRIPT1003: Expected ':'

我认为这是因为 Babel 没有将 ES6 语法(箭头函数、展开等)转换为 ES5 语法。运行 yarn build 后,我仍然在编译后的代码中看到它。

这是我的 babel.config.js:

//bable.config.js
module.exports = {
presets: [
  [ '@vue/app', {
     useBuiltIns: 'entry'
  }]
 ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的.browserslistrc

//.browserslistrc
> 1%
last 2 versions
not ie <= 8
Run Code Online (Sandbox Code Playgroud)

main.js 是这样的:

// main.js
import '@babel/polyfill'
import Vue from 'vue'
import './plugins/vuetify'
import App from './App.vue'
import router from './router'
import store from './store/store'
import { firebaseListener } from './firebaseConfig'

Vue.config.productionTip = false
Run Code Online (Sandbox Code Playgroud)

请帮我!感谢致敬。

Kai*_*r33 2

babel.config.js

  module.exports = {
     presets: [['@vue/app', { useBuiltIns: 'entry' }]],
  }
Run Code Online (Sandbox Code Playgroud)

main.js

import '@babel/polyfill' // At the top of the file, and make sure @babel/polyfill is installed
Run Code Online (Sandbox Code Playgroud)

  • 以下是[如何写出好的答案?](https://stackoverflow.com/help/how-to-answer) 的一些指南。这个提供的答案可能是正确的,但它可能会受益于解释。仅代码答案不被视为“好”答案。来自[评论](https://stackoverflow.com/review)。 (2认同)