vue 綁定事件如何傳遞參數的同時拿到事件對象


html:

 <div
    v-for="item in chatList"
    :class="item.toUserType?'patient':'doctor'"
    @touchstart.stop="gtouchstart($event,item.msgId,item)"
    @touchmove.stop="gtouchmove()"
    @touchend.stop="gtouchend(item)"
>
</div>
 
js:
    gtouchstart($even, msgId, item) {
      //  if ($even.preventDefault) $even.preventDefault();
      //  else $even.returnValue = false;

      console.log($even, "e事件",item);
      this.timer4 = setTimeout(() => {
        this.longPress($even, msgId, item.toUserType, item);
      }, 1000);
    },
就能夠獲取到事件的$event事件源+元素


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM