1:在Login.vue中通过HTTP请求获取token和用户信息//根据api接口获取tokenthis.$axios.post(url,{username:this.loginForm.username,password:this.loginForm.pass,}).then((res)=>{//console.log(res.data);this.$message.success('登录成功')letdata=res.data//根据到store中的set_token方法,将token保存到localStorage/sessionStorage,data["Authentication-Token"],获取token的值this.$store.commit('set_token',data['Authentication-Token'])}).catch((error)=>{//this.$message.error(error.status)this.loading=false//console.log(error)})2:在store.js中监控令牌状态从'vue'导入Vue从'vuex'Vue.use(Vuex)导出默认值newVuex.Store({state:{token:''},mutations:{set_token(state,token){state.token=tokensessionStorage.token=token},del_token(state){state.token=''sessionStorage.removeItem('token')}}})3:在touter/index.js
