vue中使用...扩展符为什么会报unexpected token的语法错误?

项目是vue-cli自动生成的,所以package.json中已经引入babel也应该可以解析es6语法,可是貌似报错是不能解析...扩展符?
或者是其他什么原因吗?
Add.vue报错部分代码:

import {mapActions, mapMutations} from 'vuex'
  export default{

    methods: {
      save(){
        this.saveArticle()  
      },
      ...mapActions(['saveArticle']),
      ...mapMutations(['SET_ARTICLE'])
      
    }

安装依赖如下:

  "devDependencies": {

    "autoprefixer": "^6.5.3",

    "babel-core": "^6.0.0",

    "babel-loader": "^6.0.0",

    "babel-preset-es2015": "^6.0.0",

    "babel-plugin-transform-object-rest-spread": "^6.19.0",

    "cross-env": "^3.0.0",

    "css-loader": "^0.25.0",

    "file-loader": "^0.9.0",

    "url-loader": "^0.5.7",

    "vue-loader": "^10.0.0",

    "vue-resource": "^1.0.3",

    "vue-router": "^2.0.1",

    "vue-template-compiler": "^2.1.0",

    "vuex": "^2.0.0",

    "webpack": "^2.1.0-beta.25",

    "webpack-dev-server": "^2.1.0-beta.0"

  }

控制台报错:

https://img1.mukewang.com/5bdab8f900019e4405790212.jpg

aluckdog
浏览 3248回答 1
1回答

一只萌萌小番薯

那就应该是babelrc的配置问题了,调整一下babel的依赖和配置吧
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript