setQueryParam

设置 URL 的查询参数

用法

setQueryParam 函数用于设置 URL 的查询参数。

import { setQueryParam } from '@movk/core'

setQueryParam('https://example.com', 'page', 1)
// 'https://example.com?page=1'

setQueryParam('https://example.com?page=1', 'page', 2)
// 'https://example.com?page=2'

setQueryParam('https://example.com?page=1', 'sort', 'name')
// 'https://example.com?page=1&sort=name'

API

setQueryParam(url, key, value)

设置 URL 的查询参数。

参数

url
string required
URL 字符串。
key
string required
参数名。
value
QueryParamValue required
参数值。

返回值

返回值
string
新的 URL 字符串。

Changelog

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

Copyright © 2024 - 2026 YiXuan - MIT License