const store=new Vuex.Store({ state:{ nickName:'', cartCount:0, }, mutations:{ updateUserInfo(state,nickName){ state.nickName=nickName; } }, actions:{ updateUserInfoAction(context,nickName){ context.commit('updataUserInfo',nickName) } }})//前台页面部分computed:{ nickName(){ return this.$store.state.nickName }},axios.get('/users/checkLogin').then( (response)=>{ let res=response.data; if(res.status=='0'){ this.$store.dispatch('updateUserInfoAction',res.result.userName) }} )
添加回答
举报
0/150
提交
取消