vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.42k stars 9.58k forks source link

多个文件的Action怎么导入? #354

Closed zhangjingl02 closed 8 years ago

zhangjingl02 commented 8 years ago

actionsA.js

export const progress = ({
    commit
}, num) => {
    commit(types.GLOBAL_PROGRESS, num)
}

actionsB.js

export const getData = ({
    commit
}) => {
   console.log('getData')
}

store.js


import * as actionsA from 'actionA.js'
import * as actionsB from 'actionB.js'
export default new Vuex.Store({

    /**在这里怎么同时把actionsA actionsB,作为Actions选项导入进来  **/

  actions:[actionsA,actionsB],  /**?
    modules: {
        xxx
    }
})
zhangjingl02 commented 8 years ago

补充下使用的是 vue2.0 + vuex2.0

fnlctrl commented 8 years ago

你好,请使用论坛gitter提问,issue列表只用于提交bug和feature request,谢谢!


用ES6对象展开(Object rest spread) actions:[...actionsA, ...actionsB] https://babeljs.io/docs/plugins/transform-object-rest-spread/