createStore 函数辅助
const state = user: {} /** * 多了$isAjax状态,以action为命名 如login, * 在开始请求时 * $isAjax.login 为true * 结束请求时 $isAjax.login为false **/ // $isAjax:{} const mutations = /** * mutations 做了进一步封装 req中是actions的请求参数,res中是ajax库的响应数据 * 每一个 mutation 都使用大写字母 异步请求成功为 ACTION_NAME_SUCCESS * 失败为 ACTION_NAME_FAILURE **/ { router } { windowlocation } const actions = // 返回Promise的异步请求 { return } { return } // 增加了 const getters = stateuser // $isAjax=>state.$isAjax getter // 默认是使用命名空间的 默认 namespaced:true state mutations actions getters