I know... is the spread operator of ES6. And can be used like this
var {a,...b} ={x:1,y:2,z:3};
//a=1 b={y:2,z:3}
But I really don’t understand what it means to use...mapActions() in the methods attribute of vue.
God please answer!
黄舟2017-06-12 09:34:30
mapActions() returns an object. Only after using the ... extension character can it be put into an object and be in the same methods object as the methods defined in other components.
{
methods: mapActions() // 如果没有其它组件内的定义的方法,可以这样写
}
{
methods: {
...mapActions(),// 如果有其他定义的方法
otherMethod1 () {},
otherMethod2 () {}
}
}
为情所困2017-06-12 09:34:30
Correct solution upstairs, assuming mapActions() returns
{
a() {},
b() {}
}
Then...mapActions() just takes out a and b and puts them together with other methods.
... represents two meanings, one is the remainder operator and the other is the expansion operator. The one used in your question should mean the remainder operation, and...mapActions is the expansion operator.
Details: https://developer.mozilla.org...