getQueryParams() {
const paramsString = new URLSearchParams(window.location.search).toString(); // 将查询字符串转换为字符串
const paramsArray = paramsString.split('&'); // 将字符串按 & 分割成数组
// 遍历数组,将每个参数存储到对象中
const paramsObj = {};
for (let i = 0; i < paramsArray.length; i++) {
const [key, value] = paramsArray[i].split('=');
paramsObj[decodeURIComponent(key)] = decodeURIComponent(value);
}
return paramsObj
},
标签:paramsString,const,js,字符串,paramsObj,解析,地址栏,paramsArray
From: https://www.cnblogs.com/DL-CODER/p/17404532.html