Back
VueEasyNew

What are Vue directives? Name some commonly used built-in ones

Special attributes prefixed with v-

Ideal Answer

Directives are special template attributes prefixed with v- that apply reactive behavior to the DOM. Common built-in directives:

  • v-bind (:) — bind an attribute/prop reactively
  • v-on (@) — attach event listeners
  • v-if / v-else-if / v-else — conditional rendering
  • v-show — toggle visibility via CSS display
  • v-for — list rendering
  • v-model — two-way binding
  • v-slot (#) — define named/scoped slots
  • v-html — render raw HTML (use with caution — XSS risk)
  • v-once — render once and skip future updates
  • v-memo — memoize a template subtree based on dependencies