Open powerdong opened 4 years ago
const getTargetSearch = function(key){
let url = location.search;
let result = '';
if (url.indexOf("?") != -1) {
let str = url.substr(1);
let strs = str.split("&");
for(let i = 0; i<strs.length; i++){
let obj = strs[i].split('=');
if(obj[0] == key){
result = obj[1];
return result;
}
}
}
return result;
}
当跳转页面需要携带参数时,我们通常会将所需参数通过URL地址携带过去,而在新页面如何获取携带过来的参数也是一个问题,接下来我们实现一种方法用来获取相关的参数