【发布时间】:2018-11-12 07:51:40
【问题描述】:
我对 VueJS 有点陌生,我试图在用户通过身份验证后将用户角色从登录路径传递到主页,然后我可以确定用户可以使用 v-if 看到哪些链接. 下面是我的 login.vue 代码:
this.$axios({
method: 'post',
url: 'api/role',
data: {
'email': this.username
},
headers: {'Authorization': 'Bearer '+ this.$tokens.getToken()}
})
.then(response => {
this.role = response.data['role'];
})
this.$router.push('/');
})
.catch(function(error){
console.log(error);
})
如何将“this.role”值传递给路径“/”以便从那里访问它?
【问题讨论】:
标签: javascript vue.js vuejs2 vue-component vue-router