---
title: "removeQueryParam"
description: "从 URL 中删除指定查询参数，返回不含该参数的新 URL 字符串，不修改原 URL。"
seo_title: "removeQueryParam"
seo_description: "Remove a query parameter from a URL by key and return a new URL string, leaving the rest of the query string intact."
canonical_url: "https://core.mhaibaraai.cn/docs/utilities/url/remove-query-param"
---
# removeQueryParam

> 从 URL 中删除指定查询参数，返回不含该参数的新 URL 字符串，不修改原 URL。

## 用法

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

```ts
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

See commit history for [src/utilities/url/query.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/url/query.ts).


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
