解析查询字符串
作者:
泡杯感冒灵 | 来源:发表于
2021-07-20 20:04 被阅读0次 getQueryStringArgs() {
// 取得查询字符串并去掉开头的问号
const qs = (location.search.length > 0 ? location.search.substring(1) : '');
// 保存数据的对象
const args = {};
const items = qs.length ? qs.split('&') : [];
let item = null;
let name:any = null;
let value = null;
const len = items.length;
for (let i = 0; i < len; i++) {
item = items[i].split('=');
name = decodeURIComponent(item[0]);
value = decodeURIComponent(item[1]);
if (name.length) {
args[name] = value;
}
}
return args;
}
本文标题:解析查询字符串
本文链接:https://www.haomeiwen.com/subject/uvmrmltx.html
网友评论