[Vuejs]-How to call a method every single time the field loses focus in vue.js

0👍

It should work fine, Every time field loses focus @blur event will get trigger. I just create a working sample demo for you. Can you please see and try to find the root cause of the issue you are facing.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data () {
    return {
      username: null
    }
  },
  methods: {
    checkUsername() {
      if (this.username != '') {
        console.log(this.username)
      }
    }
  }
})
<script src="https://unpkg.com/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/vue@2.x/dist/vue.js"></script>
<script src="https://unpkg.com/vuetify@2.7.1/dist/vuetify.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vuetify@2.7.1/dist/vuetify.min.css"/>
<div id="app">
  <v-text-field
    label="Username"
    v-model="username"
    @blur="checkUsername"
  ></v-text-field>
</div>

Leave a comment