IE11上的VueJS错误-SCRIPT1004:预期为';'

问题描述 投票:1回答:1

IE11-错误:SCRIPT1004:应为';'

嗨!我的网站可以在除IE之外的所有浏览器上使用。我的babel.config.js文件:

 module.exports = {
  presets: [
    ['@vue/app', {
      polyfills: [
        'es.promise',
        'es.symbol',
        'es6.array.iterator'
      ]
    }]
  ],
  "plugins": [
    "@babel/plugin-transform-shorthand-properties",
    "@babel/plugin-proposal-object-rest-spread",
    [
      'component',
      {
        libraryName: 'element-ui',
        styleLibraryName: 'theme-chalk'
      }
    ]
  ]
}

---> Console screenshot

---> Debugger screenshot

javascript vue.js internet-explorer syntax babel
1个回答
1
投票

您的调试器屏幕快照显示错误来自native-toast程序包。该软件包的GitHub显示了unresolved issue,其中使用了for ... of循环,这是导致Vue IE SCRIPT1004错误(这只是缺少的分号)的常见原因。

您可以告诉Vue CLI转换整个native-toast依赖项程序包,这是默认情况下不会执行的操作。在您的vue.config.js(不是Babel)中:

module.exports = {
  transpileDependencies: [
    'native-toast'  
  ]
}

((注:transpileDependencies是软件包名称的数组。)

显然,在某些情况下,您可能还需要在babel.config.js中使用它(首先尝试不使用它:

module.exports = {
  "presets": [
    '@babel/preset-env'
  ],
}

参考:

Vue CLI transpileDependencies

transpileDependencies

Vue CLI polyfills guide

© www.soinside.com 2019 - 2024. All rights reserved.