UNPKG

im-ui-mobile

Version:

A Vue3.0 + Typescript instant messaging component library for Uniapp

31 lines (26 loc) 565 B
import { ref } from 'vue' /** * 使用动态Refs(组合式函数) */ export function useDynamicRefs() { const refs = ref(new Map()); const setRef = (key) => (el) => { if (el) { refs.value.set(key, el); } else { refs.value.delete(key); } }; const getRef = (key) => { return refs.value.get(key); }; const getAllRefs = () => { return refs.value; }; return { refs, setRef, getRef, getAllRefs }; }