zoukankan      html  css  js  c++  java
  • vue 中input框的blur事件和enter事件同时使用时,触发enter事件时blur事件也会被触发的方法解决

    vue 中input框的blur事件和enter事件同时使用时,触发enter事件时blur事件也会被触发的方法解决


    1
    <template> 2 <input :value="val" @blur="handleBlur($event,参数1,参数2)" @keyup.enter.native="handleEnter($event,参数1,参数2)"> 3 </template> 4 <script> 5 export default { 6 data(){ 7 return { 8 isEnter: false 9 } 10 }, 11 method:{ 12 handleBlur(event,参数1,参数2){ 13 //如果回车和blur事件的代码是相同的 则不需要使用isEnter进行区分 14 if(this.isEnter) { 15 //...回车事件运行的代码 16   this.isEnter = false 17 }else { 18 // blur事件运行的代码 19 } 20 }, 21 handleEnter(event,参数1,参数2){ 22 this.isEnter = true; 23 event.target.blur(event,参数1,参数2) 24 } 25 } 26 } 27 </script>
  • 相关阅读:
    【代码笔记】JTable 、TableModel的使用3
    学习JSP(二)
    Tomcat文件配置
    学习JSP(一)
    配置elipse
    配置Jdk
    定义新运算练习题
    学习JAVA所需的东西
    学习秘籍
    总有那么一个人
  • 原文地址:https://www.cnblogs.com/ruishuiweixiang/p/14754707.html
Copyright © 2011-2022 走看看