element-plus/packages/hooks/use-prop/index.ts

8 lines
261 B
TypeScript
Raw Normal View History

import { computed, getCurrentInstance } from 'vue'
import type { ComputedRef } from 'vue'
export const useProp = <T>(name: string): ComputedRef<T | undefined> => {
2023-03-16 21:31:16 +08:00
const vm = getCurrentInstance()
return computed(() => (vm?.proxy?.$props as any)?.[name])
}