将http: //www.a.com/admin/index.php#route=main/nav&user=tom&id=123/profile
后的参数转换成:
[
{"router":"main"},
{
"nav":"",
"user":"tom",
"id":"123"
},
{"profile":""}
]除了循环变量有没有更简洁的方法
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
var url = location.search.substr(1); param = {}; console.log(url); url.replace(/([^?&]+)=([^?&]+)/g, function(s, v, k) { param[v] = decodeURIComponent(k); return k + '=' + v; }); console.log(param);