Put in order · Vue.js course · Module 15: TypeScript & Nuxt

Template Ref Usage Order

Arrange the steps for working with a typed template ref:

Items to put in order

  • Define ref<HTMLElement | null>(null)
  • Check for null: ref.value?.method()
  • Use ref in onMounted (after mounting)
  • Add ref="name" to the element in the template

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