将 URL 查询参数转化为js对象的方式{key:value} 最好的写法 function parseURLToObj() { let resObj = {} const pList = new URLSearchParams(location.search) pList.forEach((val, key) => { resObj[key] = val }) return resObj //{key:value,key2:value2} }