方法
// 解析参数
getQueryString (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
if (r != null) return (r[2]); return null
},
// 查看token
getToken () {
let queryName = this.getQueryString(GLOBAL_HIDE_MENU)
if (queryName !== null) {
queryName = decodeURIComponent(queryName) 函数可把字符串作为 URI 组件进行j解码。
//encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。
sessionStorage.setItem(GLOBAL_CHANGE_MENU, queryName)
}
},
这篇博客主要介绍了JavaScript中用于获取URL查询字符串的方法getQueryString(),以及如何使用它来检查和处理token。通过decodeURIComponent()函数解码查询字符串,然后将结果存储到sessionStorage中。该方法对于前端应用的身份验证和状态管理至关重要。

6489

被折叠的 条评论
为什么被折叠?



