1234567891011121314151617181920 |
- import { ref, onBeforeUpdate } from "vue";
- function useRefs() {
- const refs = ref([]);
- const cache = [];
- onBeforeUpdate(() => {
- refs.value = [];
- });
- const setRefs = (index) => {
- if (!cache[index]) {
- cache[index] = (el) => {
- refs.value[index] = el;
- };
- }
- return cache[index];
- };
- return [refs, setRefs];
- }
- export {
- useRefs
- };
|