mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat: add useRefs
This commit is contained in:
parent
0b147c5872
commit
5aa092519a
15
src/composition/use-refs.ts
Normal file
15
src/composition/use-refs.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { ref, onBeforeUpdate } from 'vue';
|
||||||
|
|
||||||
|
export function useRefs() {
|
||||||
|
const refs = ref([] as Element[]);
|
||||||
|
|
||||||
|
onBeforeUpdate(() => {
|
||||||
|
refs.value = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
const setRefs = (index: number) => (el: Element) => {
|
||||||
|
refs.value[index] = el;
|
||||||
|
};
|
||||||
|
|
||||||
|
return [refs, setRefs];
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user