【问题标题】:SCRIPT errors with IE 11 when using Babel and Vue.js使用 Babel 和 Vue.js 时 IE 11 出现 SCRIPT 错误
【发布时间】:2020-05-29 10:52:42
【问题描述】:

我们在 Windows 10 / IE 11 上的 Vue.js 应用程序出现问题。

在我们将babel.config 更新为以下内容之前,该应用程序一直提供SCRIPT1003: Expected ':'

module.exports = {
  presets: [
    [
      '@vue/cli-plugin-babel/preset',
      {
        targets: {
          'ie': '11'
        }
      }
    ]
  ]
}

此时错误为 SCRIPT1002: Synxax Error chunk-vendors.js (11365, 9311),这似乎与 vuelidate 节点模块有关。

看来我需要exclude上面的包,但我不明白语法应该去哪里。 我也可能需要排除多个包。

基础项目是使用vue-cli 4.4.1 构建的,并且配置文件与库存安装相差不远

【问题讨论】:

    标签: vue.js internet-explorer-11 babeljs


    【解决方案1】:

    您想转译模块吗?您可以使用webpack.config.jsbabel.config.js 中的exclude 属性来转译模块。

    你可以改变这一行:

    ...
     exclude: /node_modules/,
    ...
    

    进入这个:

    ...
      exclude: /node_modules\/(?!name-of-untranspiled-module)/,
    ...
    

    如果您需要排除多个模块,您可以像这样扩展例外列表:

    exclude: /node_modules\/(?![module1|module2])/
    

    更多信息,您可以参考this link

    【讨论】:

    • 谢谢,这正是我想要的。不幸的是,这并没有解决我遇到的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-03
    • 1970-01-01
    • 2014-06-12
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多