im/public/h5/hybrid/html/js/utils.js

11 lines
454 B
JavaScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//序列化url将url链接后面的get参数序列化成json对象
function parseUrl(url){
var param=url.substring(url.indexOf("?")+1);
var paramArr=param.split("&");
var urlArr={};
for (let i = 0; i < paramArr.length; i++) {
urlArr[paramArr[i].split("=")[0]] = decodeURI(paramArr[i].split("=")[1]);
// 将数组元素中'='左边的内容作为对象的属性名,'='右边的内容作为对象对应属性的属性值
}
return urlArr;
}