setQueryParams

GitHub查看源码
批量设置 URL 的多个查询参数,覆盖同名已有参数,返回更新后的新 URL 字符串。

用法

setQueryParams 函数用于批量设置 URL 的查询参数。

import { setQueryParams } from '@movk/core'

setQueryParams('https://example.com', { page: 1, limit: 10 })
// 'https://example.com?page=1&limit=10'

setQueryParams('https://example.com?page=1', { page: 2, sort: 'name' })
// 'https://example.com?page=2&sort=name'

API

setQueryParams(url, params)

批量设置 URL 的查询参数。

参数

url
string required
URL 字符串。
params
QueryParams required
要设置的参数对象。

返回值

返回值
string
新的 URL 字符串。

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License