解析地址栏的参数并返回一个参数对象
代码语言:javascript复制function getUrlParams() {
const searchParams = new URLSearchParams(window.location.search);
const params = {};
for(const [key, value] of searchParams) {
params[key] = value;
}
return params;
}
Usage
代码语言:javascript复制const params = getUrlParams()
参考链接
URLSearchParams