import { createStore } from 'vuex'

export default createStore({
  //state存放状态,
    state: {
        version: undefined,//需要共用的数据
        weatherData: undefined,
        axiosArr: []        
    },
    //getter为state的计算属性
    getters: {
    },
    //mutations可更改状态的逻辑，同步操作
    mutations: {
        setAxiosArr (state, cancleAjax) {
        state.axiosArr.push(cancleAjax.cancelToken)
        },
        clearAxiosArr (state) {
        let message = '路由切换中断异步请求'
        state.axiosArr.forEach(item =>{
            item()
        })
        state.axiosArr = []
        }
    },
    //提交mutation，异步操作
    actions: {
    },
    // 将store模块化
    modules: {
    }
})
