Instruction: Give an overview of how directives are used in Vue.js, including examples of common directives.
Context: This question evaluates the candidate's knowledge of Vue.js directives, their syntax, and how they are used to manipulate the DOM in Vue applications.
Official answer available
Preview the opening of the answer, then unlock the full walkthrough.
For instance, one of the most commonly used directives is v-bind, which is used to bind an attribute to an expression. Let's say we have an image tag, and we want to dynamically bind its src attribute to a property on our Vue instance. We could do it like this:
<img v-bind:src="imageSrc" />...
easy
hard
hard
hard