js 对象与 queryString 相互转换 发表于 2022-12-30 | 更新于: 2022-12-30 对象转queryString 1(new URLSearchParams(obj)).toString() queryString 转对象 12345678910const getQueryObj = () => { const query = window.location.href.split('?')[1] if (!query) return {} const obj = {} query.split('&').forEach(q => { const item = q.split('=') obj[item[0]] = item[1] }) return obj}