Question · Vue.js course · Module 15: TypeScript & Nuxt

Template Ref Type

Why do we define a template ref as ref<HTMLInputElement | null>(null)?

Answer options

  • Because TypeScript always requires null values in ref
  • Because the input may not exist in the browser
  • Because Vue does not support HTMLElement types
  • Because ref is null before the component is mounted

You can check the correct answer by solving this task in the CodeWorlds game.