猿问

关于vuex ...mapActions的问题

我知道...是ES6的扩展运算符。并且可以这样使用

var {a,...b} ={x:1,y:2,z:3};

//a=1 b={y:2,z:3}

但是我实在不理解 在 vue的methods属性中 使用...mapActions()这样的方式 是什么意思。
大神求解答!


MMMHUHU
浏览 515回答 1
1回答

尚方宝剑之说

mapActions() 返回的是一个对象, 用了 ... 扩展符后,才可以放进一个对象里,和其他组件内定义的 method 在同一个 methods 对象。{    methods: mapActions() // 如果没有其它组件内的定义的方法,可以这样写}{    methods: {        ...mapActions(),// 如果有其他定义的方法        otherMethod1 () {},        otherMethod2 () {}    }}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答