removeQueryParam

GitHub查看源码
从 URL 中删除指定查询参数,返回不含该参数的新 URL 字符串,不修改原 URL。

用法

removeQueryParam 函数用于删除 URL 的指定查询参数。

import { removeQueryParam } from '@movk/core'

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

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

API

removeQueryParam(url, key)

删除 URL 的指定查询参数。

参数

url
string required
URL 字符串。
key
string required
要删除的参数名。

返回值

返回值
string
新的 URL 字符串。

Changelog

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