store.js 454 B

1234567891011121314151617181920212223242526272829
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import * as actions from './actions'
  4. import * as getters from './getters'
  5. Vue.use(Vuex)
  6. // 应用初始状态
  7. const state = {
  8. count: 10
  9. }
  10. // 定义所需的 mutations
  11. const mutations = {
  12. INCREMENT(state) {
  13. state.count++
  14. },
  15. DECREMENT(state) {
  16. state.count--
  17. }
  18. }
  19. // 创建 store 实例
  20. export default new Vuex.Store({
  21. actions,
  22. getters,
  23. state,
  24. mutations
  25. })