Intermediate
What are Vue directives and how do they work?
Vue directives are special tokens in the markup that tell the library to do something to a DOM element. They are prefixed with a v- to indicate that they are Vue-specific. Directives provide reactive functionality and enhance the template syntax.
Here’s how they work:
- Binding: Directives bind data to the DOM.
- Modifiers: You can apply modifiers to alter the directive's behavior.
- Examples: Common directives include v-bind, v-model, and v-for.
Example of using v-bind:
<div v-bind:class="{ active: isActive }">Hello</div>