@pmun/utils / parseQueryString
Function: parseQueryString()
ts
function parseQueryString(url, options?): Record<string, any>;将 URL 查询参数字符串解析为 JavaScript 对象(字面量)
Parameters
url
string
需要解析的 URL 字符串或查询参数字符串
options?
解析选项
Returns
Record<string, any>
解析后的对象
Example
ts
parseQueryString('?name=John&age=30&isDeveloper=true')
// 返回: { name: 'John', age: 30, isDeveloper: true }
parseQueryString('https://example.com/page?tags=js&tags=ts')
// 返回: { tags: ['js', 'ts'] }
parseQueryString('info=%7B%22city%22%3A%22Beijing%22%7D')
// 返回: { info: { city: 'Beijing' } }