@nomnes/vue-autofocus
Autofocus directive for Vue
npm install @nomnes/vue-autofocus
yarn add @nomnes/vue-autofocus
Usage
import Vue from "vue";
import autofocus from "@nomnes/vue-autofocus";
Vue.use(autofocus);
or
import Vue from "vue";
import { autofocus } from "@nomnes/vue-autofocus";
Vue.directive("autofocus", autofocus);
and then in template:
<input v-autofocus/>
Options
When used as a plugin, the name of the directive can be passed using the options:
import Vue from "vue";
import autofocus from "@nomnes/vue-autofocus";
Vue.use(autofocus, { name: 'autofocus' });