获取后台返回的URL中的Token
获取后台返回的URL中的TokenApp.vue中// An highlighted blockmethods: {init() {var url = window.location.href;//access_token是后台所指定的keyif (url.indexOf('access_token') != -1) {//登录跳转...
·
获取后台返回的URL中的Token
App.vue中
// An highlighted block
methods: {
init() {
var url = window.location.href;
//access_token是后台所指定的key
if (url.indexOf('access_token') != -1) {
//登录跳转
let str = url.split('#')[1];
let a = url.split('#')
let arr = str.split('&');
let json = {};
let token = '';
let state = '';
let tenant = '';
let userid = '';
for (var i = 0; i < arr.length; i++) {
let arr2 = arr[i].split('=');
json[arr2[0]] = arr2[1];
}
token = json['/access_token'];
tenant = json['tenant_id'];
userid = json['user_id'];
let user = json['username'];
this.$router.push({ path:'/'})
this.$cookies.set('CookieToken', token)
console.log('查看所有cookie=',this.$cookies.keys())
console.log('查看返回的url中的所有信息=json==', json)
} else {
//做登录跳转
}
},
更多推荐
已为社区贡献1条内容
所有评论(0)