js 解析地址栏参数
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
},