vuex中的babel编译mapGetters/mapActions报错解决方法

vex使用...mapActions报错解决办法

vuex2增加了mapGetters和mapActions的方法,借助stage2的Object Rest Operator

所在通过

methods:{

    ...mapActions([

         'increment'

     ])

}

酱紫去拿到action。但是我们需要安装babel-preset-stage-2的依赖。

 

 

可以使用babel插件, 该插件为

babel-plugin-transform-object-rest-spread

使用方法:

npm install --save-dev babel-plugin-transform-object-rest-spread

新建.babelrc配置文件(切记不要忘记!!!)
{
    "plugins": ["transform-object-rest-spread"]
}
谢谢大家!!!
posted @ 2018-07-09 17:36  学富五车  阅读(410)  评论(0编辑  收藏  举报