Skip to content

useRouteHash

反应式 route.hash 的简写。

¥Shorthand for a reactive route.hash. Available in the @vueuse/router add-on.

用法

¥Usage

ts
import { useRouteHash } from '@vueuse/router'

const search = useRouteHash()

console.log(search.value) // route.hash
search.value = 'foobar' // router.replace({ hash: 'foobar' })

类型声明

typescript
export declare function useRouteHash(
  defaultValue?: MaybeRefOrGetter<RouteHashValueRaw>,
  { mode, route, router }?: ReactiveRouteOptions,
): Ref<RouteHashValueRaw, RouteHashValueRaw>

源代码

源代码文档

变更日志

v12.8.0 on 3/5/2025
7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)

VueUse v13.0 中文网 - 粤ICP备13048890号