Skip to content

Commit 9347501

Browse files
authored
Add reactivity information in Options API to Template Refs page
1 parent b70003e commit 9347501

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/guide/essentials/template-refs.md

+21
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,24 @@ export default {
346346
In the above example, a parent referencing this component via template ref will only be able to access `publicData` and `publicMethod`.
347347

348348
</div>
349+
350+
<div class="options-api">
351+
352+
## Reactivity of Refs {#reactivity-of-refs}
353+
354+
Note that `this.$refs` is not reactive. For a reactive ref, you can use `useTemplateRef`:
355+
356+
```vue
357+
<script>
358+
export default {
359+
setup() {
360+
useTemplateRef('input')
361+
}
362+
}
363+
</script>
364+
365+
<template>
366+
<input ref="input" />
367+
</template>
368+
```
369+
</div>

0 commit comments

Comments
 (0)