简体   繁体   English

IE11 + Vue-Cli + Webpack + Babel - SCRIPT1003 错误

[英]IE11 + Vue-Cli + Webpack + Babel - SCRIPT1003 Error

I have the SCRIPT1003: Expected ':' error in IE11.我有SCRIPT1003: Expected ':' IE11 错误。 I have installed vuejs over vue-cli tool.我已经通过 vue-cli 工具安装了 vuejs。 It worked until I have added vuex library to the package.json.它一直有效,直到我将 vuex 库添加到 package.json。 My package.json dependencies are following:我的package.json依赖项如下:

"dependencies": {
    "axios": "^0.16.2",
    "babel-polyfill": "^6.26.0",
    "lodash": "^4.17.4",
    "rxjs": "^5.4.2",
    "vue": "^2.3.3",
    "vue-i18n": "^7.1.0",
    "vue-router": "^2.6.0",
    "vue-rx": "^3.3.0",
    "vuetify": "^0.14.11",
    "vuex": "^2.3.1",
    "vuex-persistedstate": "^2.0.0"
  }

As suggested on many other help forums I have tried using babel polyfill.正如许多其他帮助论坛所建议的那样,我尝试使用 babel polyfill。 My .babelrc file is like so:我的.babelrc文件是这样的:

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["istanbul"]
    }
  }
}

I have included the polyfill in the entry point in build/webpack.base.conf.js :我已经将polyfill包含在build/webpack.base.conf.js的入口点中:

entry: {
  app: ['babel-polyfill', './src/main.js']
},

Unfortunately I am still getting the same error after all of this.不幸的是,在这一切之后,我仍然遇到同样的错误。 Could you please help me how to make it work in IE11?你能帮我如何让它在 IE11 中工作吗?

Thank you in advance.提前谢谢你。

Best regards,最好的问候,

Goran戈兰

You are getting this error, most likely, because somewhere in your code you've written an object literal with a shorthand property .您收到此错误很可能是因为您在代码中的某处编写了一个带有速记属性的对象文字。

The most likely culprit would when passing the Vuex store in the constructor for your main Vue instance:在主 Vue 实例的构造函数中传递 Vuex store时,最有可能的罪魁祸首是:

new Vue({
  el: '#app',
  store,
  // ...
});

IE11 doesn't support shorthand properties, so it's letting you know it's expecting the : needed to define the property value: IE11 不支持速记属性,因此它让您知道它期望:定义属性值:

new Vue({
  el: '#app',
  store: store,
  // ...
})

Got an answer from Vue.js forum:从 Vue.js 论坛得到答案:

https://forum.vuejs.org/t/ie11-vue-cli-webpack-babel-script1003-error/16257/6 https://forum.vuejs.org/t/ie11-vue-cli-webpack-babel-script1003-error/16257/6

The problem was that had added vCardMedia in a component:问题是在组件中添加了 vCardMedia:

components : {
 vCardMedia
}

Once I removed it everything works with babel included.一旦我删除了它,一切都可以与 babel 一起使用。 Still not sure why the component is breaking it though...仍然不确定为什么组件会破坏它...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM