You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
532 B
23 lines
532 B
/** |
|
* @program: kicc-ui |
|
* @description: vue数据响应式处理工具 |
|
* @author: entfrm开发团队-王翔 |
|
* @create: 2022/4/10 |
|
*/ |
|
|
|
import type { Ref } from 'vue'; |
|
import { ref, onBeforeUpdate } from 'vue'; |
|
|
|
export function useRefs(): [Ref<HTMLElement[]>, (index: number) => (el: HTMLElement) => void] { |
|
const refs = ref([]) as Ref<HTMLElement[]>; |
|
|
|
onBeforeUpdate(() => { |
|
refs.value = []; |
|
}); |
|
|
|
const setRefs = (index: number) => (el: HTMLElement) => { |
|
refs.value[index] = el; |
|
}; |
|
|
|
return [refs, setRefs]; |
|
}
|
|
|