index.ts 272 B

1234567
  1. import { computed, getCurrentInstance } from 'vue'
  2. import type { ComputedRef } from 'vue'
  3. export const useProp = <T>(name: string): ComputedRef<T | undefined> => {
  4. const vm = getCurrentInstance()!
  5. return computed(() => (vm.proxy?.$props as any)[name] ?? undefined)
  6. }