Skip to content

Commit

Permalink
Add useRouteQuery composable
Browse files Browse the repository at this point in the history
  • Loading branch information
hungify committed Mar 28, 2024
1 parent 22b456b commit a8f1e81
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/composables/use-route-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { LocationQuery } from 'vue-router/auto'
import { getRouteQuery } from '#/utils/route'

export const useRouteQuery = <T extends LocationQuery>() => {
const route = useRoute()

const fnRouteQuery = computed(() => {
return getRouteQuery<T>(route.query as T)('fn')
})

const valRouteQuery = computed(() => {
return getRouteQuery<T>(route.query as T)('val')
})

return {
valRouteQuery,
fnRouteQuery,
}
}

0 comments on commit a8f1e81

Please sign in to comment.