Object.fromEntries(new URLSearchParams(window.location.search))
// Result: { hello : "nihao", year : 2023 }
- Object.fromEntries:把键值对列表转换为一个对象,这个办法是和 Object.entries() 绝对的。
Object.fromEntries([
['foo', 1],
['bar', 2]
])
// {foo: 1, bar: 2}
- new URLSearchParams
发表回复