Javascript获取GET参数
2021-02-20 09:20
标签:获取 split 技术 script pre str function var href 链接: https://example.com?id=1&type=2 Javascript获取GET参数 标签:获取 split 技术 script pre str function var href 原文地址:https://www.cnblogs.com/shih945/p/12682854.htmlfunction getQueryVariable() {
let query = window.location.search.substring(1);
let key_values = query.split("&");
let params = {};
key_values.map(key_val => {
let key_val_arr = key_val.split("=");
params[key_val_arr[0]] = key_val_arr[1];
});
return params;
}