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>
SUPER SALE
Get a yearly plan for a massive 50% OFF
+ 2 Masterclass Courses + Free Workshop
Ends in
00hours
:
08minutes
:
39seconds
:
SUPER SALE
Get a yearly plan for a massive 50% OFF
+ 2 Masterclass Courses + Free Workshop
Ends in
00
hours
:
08
minutes
:
39
seconds
: