useRouteQuery
Shorthand for reactive route.query available in add-on @vueuse/router
Usage
import { useRouteQuery } from '@vueuse/router'
const search = useRouteQuery('search')
const search = useRouteQuery('search', 'foo') // or with a default value
console.log(search.value) // route.query.search
search.value = 'foobar' // router.replace({ query: { search: 'foobar' } })
import { useRouteQuery } from '@vueuse/router'
const search = useRouteQuery('search')
const search = useRouteQuery('search', 'foo') // or with a default value
console.log(search.value) // route.query.search
search.value = 'foobar' // router.replace({ query: { search: 'foobar' } })
Type Declarations
export declare function useRouteQuery(
name: string
): Ref<null | string | string[]>
export declare function useRouteQuery<
T extends null | undefined | string | string[] = null | string | string[]
>(name: string, defaultValue?: T, options?: ReactiveRouteOptions): Ref<T>
export declare function useRouteQuery(
name: string
): Ref<null | string | string[]>
export declare function useRouteQuery<
T extends null | undefined | string | string[] = null | string | string[]
>(name: string, defaultValue?: T, options?: ReactiveRouteOptions): Ref<T>
Source
Contributors
Anthony Fu
Sacha STAFYNIAK
reslear
Marshall Thompson