You're seeking the blur
event, which occurs when the <input>
loses focus. Use Vue syntax to add a blur
-event listener 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)
}
}
})
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<div id="app">
<input @blur="handleBlur" placeholder="first name">
<input @blur="handleBlur" placeholder="last name">
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…