Vue.js · Hook
useTemplateRef
useTemplateRef returns a shallow ref linked to a DOM element or child component with a matching ref attribute. Use it after mounting to access that element or component safely.
Last updated
Syntax
function useTemplateRef<T>(key: string): Readonly<ShallowRef<T | null>>In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
onMounted()ref()watchEffect()Typing Template RefsFunction Refs