nuxt.ts 203 B

123456
  1. import type { ComputedRef } from 'vue'
  2. export function useRouteParam<T>(name: string, init?: T): ComputedRef<T> {
  3. const route = useRoute()
  4. return computed(() => route.params[name] as any ?? init)
  5. }