store.js 530 B

123456789101112131415161718192021222324252627282930313233
  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. isDing: false
  10. }
  11. // 定义所需的 mutations
  12. const mutations = {
  13. INCREMENT(state) {
  14. state.count++
  15. },
  16. DECREMENT(state) {
  17. state.count--
  18. },
  19. isDingFun(state){
  20. state.isDing = true
  21. }
  22. }
  23. // 创建 store 实例
  24. export default new Vuex.Store({
  25. actions,
  26. getters,
  27. state,
  28. mutations
  29. })