mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-02 20:18:22 +08:00
75cf264040
* refactor: tabs * refactor: tabs * fix: tabs hotreload error * refactor: rename useRef * feat: add leftExtra rightExtra * refactor: tabs * test: update tabs test * refactor: card * doc: update tabs demo * refactor: add card style * style: update vue dep
21 lines
574 B
TypeScript
21 lines
574 B
TypeScript
import type { Ref, ComponentPublicInstance } from 'vue';
|
|
import { onBeforeUpdate, ref } from 'vue';
|
|
import type { Key } from '../type';
|
|
|
|
type RefType = HTMLElement | ComponentPublicInstance;
|
|
export type RefsValue = Map<Key, RefType>;
|
|
type UseRef = [(key: Key) => (el: RefType) => void, Ref<RefsValue>];
|
|
const useRefs = (): UseRef => {
|
|
const refs = ref<RefsValue>(new Map());
|
|
|
|
const setRef = (key: Key) => (el: RefType) => {
|
|
refs.value.set(key, el);
|
|
};
|
|
onBeforeUpdate(() => {
|
|
refs.value = new Map();
|
|
});
|
|
return [setRef, refs];
|
|
};
|
|
|
|
export default useRefs;
|