Put in order · Vue.js course · Module 2: Template Syntax
Template Ref Lifecycle
Order the steps of using a template ref:
Items to put in order
- onMounted: the element is available
- Template: ref="inputRef" on the element
- Declaration: const inputRef = ref(null)
- Usage: inputRef.value?.focus()
Show the answer
Correct order:
- Declaration: const inputRef = ref(null)
- Template: ref="inputRef" on the element
- onMounted: the element is available
- Usage: inputRef.value?.focus()