store.js 945 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. dataLoading: true, // 需要转译的情况下日报页面显示加载
  11. timer: null
  12. }
  13. // 定义所需的 mutations
  14. const mutations = {
  15. INCREMENT(state) {
  16. state.count++
  17. },
  18. DECREMENT(state) {
  19. state.count--
  20. },
  21. isDingFun(state){
  22. state.isDing = true
  23. },
  24. upDataLoading(state) {
  25. setTimeout(()=>{
  26. state.dataLoading = false
  27. console.log(state.dataLoading, '看看他的值')
  28. }, 1000)
  29. // state.timer = setTimeout(()=>{
  30. // clearTimeout(state.timer)
  31. // state.dataLoading = false
  32. // }, 1800000)
  33. }
  34. }
  35. // 创建 store 实例
  36. export default new Vuex.Store({
  37. actions,
  38. getters,
  39. state,
  40. mutations
  41. })