Ułóż w kolejności · Kurs Vue.js · Moduł 2: Składnia szablonów

Cykl życia template ref

Uporządkuj kroki użycia template ref:

Elementy do ułożenia

  • onMounted: element jest dostępny
  • Template: ref="inputRef" na elemencie
  • Deklaracja: const inputRef = ref(null)
  • Użycie: inputRef.value?.focus()
Pokaż odpowiedź

Poprawna kolejność:

  1. Deklaracja: const inputRef = ref(null)
  2. Template: ref="inputRef" na elemencie
  3. onMounted: element jest dostępny
  4. Użycie: inputRef.value?.focus()