mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +08:00
16 lines
383 B
TypeScript
16 lines
383 B
TypeScript
import type { Ref } from 'vue';
|
|
import { onBeforeUpdate, ref } from 'vue';
|
|
|
|
export type UseRef = [(el: any, key: string | number) => void, Ref<any>];
|
|
|
|
export const useRef = (): UseRef => {
|
|
const refs = ref<any>({});
|
|
const setRef = (el: any, key: string | number) => {
|
|
refs.value[key] = el;
|
|
};
|
|
onBeforeUpdate(() => {
|
|
refs.value = {};
|
|
});
|
|
return [setRef, refs];
|
|
};
|