直接上代码
getUrlParams(params) {
let url = window.location.search; //获取当前页面的url的地址
var theRequest = new Object();
if (url.indexOf("?") != -1) {
url = url.split('?')[1];
var str = url.substr(0);
var strs = str.split("&");
strs.splice("?", 0);
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
}
}
return theRequest
}
(#^.^#),这样就可以拿到 theRequest当前的对象的所有键值对。