Question · Vue.js course · Module 2: Template Syntax

Accessing DOM via Template Ref

Which Vue mechanism gives direct access to a DOM element from the component's template?

Answer options

  • document.querySelector()
  • v-access
  • You cannot in Vue
  • Use ref="name" and const name = ref(null)
Show the answer

Correct answer:

  • Use ref="name" and const name = ref(null)