/ Form

Autofocus directive for Vue

Autofocus directive for Vue

vue-autofocus-directive

Autofocus directive for Vue

When the page loads, the element with the directive gains focus (note: autofocus doesn’t work on mobile Safari).

Installation

npm install --save vue-autofocus-directive

npm package link

import Vue from 'vue';
import autofocus from 'vue-autofocus-directive';
Vue.directive('autofocus', autofocus);

Example

<template>
  <form>
    <label>Email</label>
    <input v-autofocus v-model="email"  type="email" name="email" placeholder="Email">
  </form>
</template>

Powered by

  • Babel
  • Webpack 4

GitHub