有没有更好的方法将 URL 的 location.search 转换为对象?也许只是更有效或更精简?我正在使用 jQuery,但纯 JS 也可以工作。
var query = window.location.search.substring(1), queryPairs = query.split('&'), queryJSON = {};
$.each(queryPairs, function() { queryJSON[this.split('=')[0]] = this.split('=')[1]; });