Directives
Directives play an important role in a Vue application. They reactively apply changes to the DOM when the value of its expression changes. For example, v-for renders the element or data block multiple times based on the source data, and v-on attaches listeners to a DOM element. Besides using the built-in directives, you can also create custom directives. To do that, you create directive definition objects and register them, either globally using Vue.directive() or locally to a component by using the directives property of that component.
In the definition object of a directive, you can add the following hook functions for Vue.js to notify the directive about what happens outside so that it can apply different logic accordingly: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access