1. 程式人生 > >vue ...mapActions()含義 (es6 剩餘操作符)

vue ...mapActions()含義 (es6 剩餘操作符)

mapActions() 返回的是一個物件, 用了 ... 擴充套件符後,才可以放進一個物件裡,和其他元件內定義的 method 在同一個 methods 物件。

{
    methods: mapActions() // 如果沒有其它元件內的定義的方法,可以這樣寫
}
{
    methods: {
        ...mapActions(),// 如果有其他定義的方法
        otherMethod1 () {},
        otherMethod2 () {}
    }
}
https://segmentfault.com/q/1010000009658513