【问题标题】:IE11 SCRIPT1002 syntax error with => in main.js babel and webpackIE11 SCRIPT1002 语法错误与 main.js babel 和 webpack 中的 =>
【发布时间】:2019-04-04 10:52:42
【问题描述】:

我在带有 ES6 和 Babel 的 IE11 中收到错误 SCRIPT1002 syntax error

我发现这是由于我的打字稿代码中的箭头函数=>

我正在使用

  • Vue
  • webpack: "^4.20.2",
  • @babel/core: "^7.1.2"`

我试过关注.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "modules": false,
        "targets": {
          "browsers": [ "> 1%", "last 2 versions", "not ie <= 8" ]
        },
        "useBuiltIns": false
      }
    ]
  ]
}

【问题讨论】:

    标签: vue.js webpack babeljs babel-loader babel-polyfill


    【解决方案1】:

    尝试添加transform-es2015-arrow-functions babel 插件。如果您仍然会遇到类似的错误 - 尝试分析您的捆绑包的代码并找出其中的 ES6 feature not supported by IE11 并为它们添加插件。

    【讨论】:

    • 它通过改变 tsconfig.json 文件 "module": "esnext" 中的 "module" 值来工作
    猜你喜欢
    • 2018-05-20
    • 1970-01-01
    • 2018-01-06
    • 2017-12-26
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多