templateRef
Shorthand for binding ref to template element.
Usage
vue
<script lang="ts">
import { templateRef } from '@vueuse/core'
export default {
setup() {
const target = templateRef('target')
// no need to return the `target`, it will bind to the ref magically
},
}
</script>
<template>
<div ref="target" />
</template>
With JSX/TSX
tsx
import { templateRef } from '@vueuse/core'
export default {
setup() {
const target = templateRef<HTMLElement | null>('target', null)
// use string ref
return () => <div ref="target"></div>
},
}
<script setup>
Build smarter with AI
Become an AIDD Insider
Secure early access + the best pricing & perks we'll ever offer. 24H only
04days
:
19hours
:
45minutes
:
12seconds
:
Build smarter with AI
Become an AIDD Insider
Secure early access + the best pricing & perks we'll ever offer. 24H only
04
days
:
19
hours
:
45
minutes
:
12
seconds
: