let url = ‘https://i-beta.cnblogs.com/posts/edit?param1=123¶m2=second‘
let arr = url.split(‘&‘);
let obj = new Object();
for (var i = 0; i < arr.length; i++) {
obj[arr[i].split(‘=‘)[0]] = arr[i].split(‘=‘)[1];
}
执行后这里的obj = {param:‘123‘,
param2:‘second‘}
原文地址:https://www.cnblogs.com/wangxiaoer5200/p/12053607.html
时间: 2024-11-10 12:51:26