useRouteHash
对响应式的 route.hash
的简写。 Available in the @vueuse/router add-on.
用法
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>
源码
贡献者
Anthony Fu
一纸忘忧
Anthony Fu
Antério Vieira
Lindsay Gaines
Dvir Hazout
Curt Grimes
更新日志
v12.3.0
on 1/2/202559f75
- feat(toValue): deprecate toValue
from @vueuse/shared
in favor of Vue's nativev12.0.0-beta.1
on 11/21/2024v11.0.0-beta.3
on 8/14/2024965bf
- fix(useRouteHash, useRouteParams, useRouteQuery): fix effect triggering multiple times (#4113)v10.3.0
on 7/30/20230d02f
- fix(router): improves router functions: synchronize values, adds tests, and optimize performance (#3184)v10.2.0
on 6/16/2023