How to use onfocusout function in vue.js?

Use the v-on directive to add an event listener for blur or focusout on the <input>:

v-on:EVENT_NAME="METHOD"

Example:

<input v-on:blur="handleBlur">

Or shorter syntax:

@EVENT_NAME="METHOD"

Example:

<input @blur="handleBlur">

new Vue({
  el: '#app',
  methods: {
    handleBlur(e) {
      console.log('blur', e.target.placeholder)
    },
    handleFocusout(e) {
      console.log('focusout', e.target.placeholder)
    }
  }
})
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>

<div id="app">
  <fieldset>
    <legend>blur</legend>
    <input @blur="handleBlur" placeholder="first name">
    <input @blur="handleBlur" placeholder="last name">
  </fieldset>
  <fieldset>
    <legend>focusout</legend>
    <input @focusout="handleFocusout" placeholder="email">
    <input @focusout="handleFocusout" placeholder="phone">
  </fieldset>
</div>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)