url:
http://localhost:81/login?redirect=%2Findex&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvdUV4dGVybmFsSWQiOiI0OTI2MjYzMTIxMDU1NDAxMTM4IiwiYXVkIjpbImVudGVycHJpc2VfbW9iaWxlX3Jlc291cmNlIiwiYmZmX2FwaV9yZXN
截取参数:
let url = window.location.href ; //获取当前url let dz_url = url.split('#')[0]; //获取#/之前的字符串 let cs = dz_url.split('?')[1]; //获取?之后的参数字符串 let cs_arr = cs.split('&'); //参数字符串分割为数组 let params = {}; // 遍历数组,将键值对保存到params对象中 cs_arr.forEach(pair => { let keyValue = pair.split('='); params[keyValue[0]] = keyValue[1]; }); // 提取access_token的值 let accessToken = params['access_token'];