| Category | Component |
|---|---|
| Export Size | 165 B |
| Last Changed | 2 weeks ago |
Unref for dom element.
<template>
<div ref="div"/>
<HelloWorld ref="hello"/>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { unrefElement } from '@vueuse/core'
const div = ref() // will be bind to the <div> element
const hello = ref() // will be bind to the HelloWorld Component
onMounted(() => {
console.log(unrefElement(div)) // the <div> element
console.log(unrefElement(hello)) // the root element of the HelloWorld Component
})
</script>
export type VueInstance = ComponentPublicInstance export type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T> export type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T> export type MaybeElement = | HTMLElement | SVGElement | VueInstance | undefined | null export type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined /** * Get the dom element of a ref of element or Vue component instance * * @param elRef */ export declare function unrefElement<T extends MaybeElement>( elRef: MaybeComputedElementRef<T> ): UnRefElementReturn<T>
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/core/unrefElement/