hasQueryParam

检查 URL 是否包含指定查询参数

用法

hasQueryParam 函数用于检查 URL 是否包含指定查询参数。

import { hasQueryParam } from '@movk/core'

hasQueryParam('https://example.com?page=1', 'page') // true
hasQueryParam('https://example.com?page=1', 'sort') // false
hasQueryParam('https://example.com?flag', 'flag') // true (无值参数)

API

hasQueryParam(url, key)

检查 URL 是否包含指定查询参数。

参数

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

返回值

返回值
boolean
是否包含该参数。

Changelog

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

Copyright © 2024 - 2026 YiXuan - MIT License