Directives in Vue are special attributes prefixed with v-
, used to apply behaviors to the DOM. Custom directives are created by using Vue.directive
and are ideal for DOM manipulations or reusing custom logic. For example:
Vue.directive('focus', { inserted: function (el) { el.focus(); } });