Home  >  Article  >  Web Front-end  >  What is the lost focus event in vuejs

What is the lost focus event in vuejs

青灯夜游
青灯夜游Original
2021-09-27 19:28:4611233browse

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>

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!

Statement:
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
Previous article:Is vuejs an API?Next article:Is vuejs an API?