+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>

Related questions

0 votes
asked May 14, 2019 in Other by Robindeniel
0 votes
asked Feb 4, 2020 in VueJS by rajeshsharma
...