Click in order · Vue.js course · Module 2: Template Syntax

Template Ref Syntax with onMounted

Arrange the template ref code with auto-focus:

Items to click

  • inputRef.value?.focus()
  • onMounted(() => {
  • const inputRef = ref(null)
  • })
Show the answer

Correct order:

  1. const inputRef = ref(null)
  2. onMounted(() => {
  3. inputRef.value?.focus()
  4. })