import Vue from 'vue' import Vuex from 'vuex' import * as actions from './actions' import * as getters from './getters' Vue.use(Vuex) // 应用初始状态 const state = { count: 10, isDing: false, dataLoading: true, // 需要转译的情况下日报页面显示加载 timer: null } // 定义所需的 mutations const mutations = { INCREMENT(state) { state.count++ }, DECREMENT(state) { state.count-- }, isDingFun(state){ state.isDing = true }, upDataLoading(state) { setTimeout(()=>{ state.dataLoading = false console.log(state.dataLoading, '看看他的值') }, 1000) // state.timer = setTimeout(()=>{ // clearTimeout(state.timer) // state.dataLoading = false // }, 1800000) } } // 创建 store 实例 export default new Vuex.Store({ actions, getters, state, mutations })