+1 vote
in VueJS by

How do you register directives locally?

1 Answer

0 votes
by

You can also register directives locally(apart from globally) using directives option in component as below,

directives: {

  focus: {

    // directive definition

    inserted: function (el) {

      el.focus()

    }

  }

}

Now you can use v-focus directive on any element as below,

<input v-focus>

...