You can also register directives locally(apart from globally) using directives option in component as below:
1 2 3 4 5 6 7 8 |
directives: { focus: { // directive definition inserted: function (el) { el.focus() } } } |
Now you can use v-focus directive on any element as below,
1 |
<input v-focus> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.