const state = () => ({ userInfo: {}, }) const mutations = { // 设置用户信息 SET_USER_INFO(state, data) { state.userInfo = data }, } const actions = { // 退出登录 logout({ commit }) { commit('SET_USER_INFO', {}) }, // 用户登录 login({ commit }, data) { commit('SET_USER_INFO', data) }, } export default { namespaced: true, state, mutations, actions, }