Home > Web Front-end > Front-end Q&A > What is the lost focus event in vuejs

What is the lost focus event in vuejs

青灯夜游
Release: 2023-01-11 09:22:41
Original
11364 people have browsed it

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.

What is the lost focus event in vuejs

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template