共计 397 个字符,预计需要花费 1 分钟才能阅读完成。
// 获取 url
console.log(window.location.search)
var urlParams = new Object();
urlParams = this.getParams();
this.id = urlParams['id'];
this.name = urlParams['name'];
console.log(id, name)
getParams() {
var url = location.search;
var params = new Object();
if (url.indexOf("?") != -1) {var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {params[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return params;
}
正文完
发表至: javascript
2022-06-30