Home > Article > Web Front-end > What is the lost focus event in vuejs
The lost focus event in vuejs is "@blur". This event will be triggered when the element loses focus. How to use it: Add the "@blur="event handler"" statement to the tag template to bind the event , just use JavaScript to set the code that needs to be executed when the event is triggered.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
@blur
is an event triggered when an element loses focus
@focus
is an event triggered when an element gains focus
Example:
<template> <div> <!-- @blur 当元素失去焦点时触发blur事件 --> <div> <input type="text" placeholder="请输入内容" @blur="blurText"/> </div> </div> </template> <script> export default { name: "commitText", methods:{ blurText(){ console.log("blur事件被执行了") } } } </script> <style scoped> </style>
Related recommendations: "vue.js Tutorial"
The above is the detailed content of What is the lost focus event in vuejs. For more information, please follow other related articles on the PHP Chinese website!