parseQuery

解析 URL 查询字符串为对象

用法

parseQuery 函数用于解析 URL 查询字符串为对象。

import { parseQuery } from '@movk/core'

parseQuery('?name=John&age=30')
// { name: 'John', age: '30' }

parseQuery('tags=a&tags=b&tags=c')
// { tags: ['a', 'b', 'c'] }

parseQuery('encoded=%E4%B8%AD%E6%96%87')
// { encoded: '中文' }

API

parseQuery(search)

解析 URL 查询字符串为对象。

参数

search
string required
查询字符串(可带或不带 ?)。

返回值

返回值
Record<string, string | string[]>
解析后的查询参数对象。

Changelog

7c832 — refactor!: 重构模块架构,拆分 utils 为专业化模块

Copyright © 2024 - 2026 YiXuan - MIT License