Autofocus directive for Vue
AboutLifted from the official Vue tutorial: https://vuejs.org/v2/guide/custom-directive.html
When the page loads, the element with the directive gains focus (note: autofocus doesnât work on mobile Safari).
InstallationUsagenpm install --save vue-autofocus-directive
Optionsimport Vue from "vue";
import autofocus from "vue-autofocus-directive";
Vue.directive("autofocus", autofocus);
binding
value
undefined
<template>
  <form>
    <label>Email</label>
    <input
      v-autofocus
      v-model="email"
      type="email"
      name="email"
      placeholder="Email"
    />
  </form>
</template>
or
<template>
  <form>
    <label>Email</label>
    <input
      v-autofocus="dynamicValue"
      v-model="email"
      type="email"
      name="email"
      placeholder="Email"
    />
  </form>
</template>
Â
<script>
export default {
  data() {
    return {
      dynamicValue: false
    };
  }
};
</script>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4