h5长按事件

2022-10-23 11:32:56 阅读:2 编辑
<div  class="t-conversation-item" v-for="(item,index) in conversationList" :data-index="index" @click="onChat"
              @touchstart="longPress" @touchend="removePress" @touchmove="touchmove"
               :style="'background-color: '+(item.isPinned == 1 ? '#F4F5F9':'#ffffff')+';'" >
 data: function () {
        return {
          isLongpress:false,
          touchstartTime:0,
          }
          }
longPress( e) {
        this.touchstartTime = new Date().getTime()
        this.isLongpress = true
      },
      removePress(e) {
        console.log("removePress",e);
        this.touchendTime = new Date().getTime()
        let duration = this.touchendTime - this.touchstartTime
        if ( this.isLongpress && duration >= 600) {
          this.showFun(e);
        }
      },
      touchmove () {
        this.isLongpress = false
      },