FurBall/uni_modules/tuniaoui-vue3/hooks/use-prop/index.ts

11 lines
346 B
TypeScript

import { computed, getCurrentInstance } from 'vue'
import { isEmptyVariableInDefault } from '../../utils'
import type { ComputedRef } from 'vue'
export const useProp = <T>(name: string): ComputedRef<T | undefined> => {
const vm = getCurrentInstance()
return computed(
() => isEmptyVariableInDefault(vm?.proxy?.$props as any)[name]
)
}