Vue-- press elements to achieve certain operating

  First, describe the demand, it is hoped to achieve a certain operation at the time of press elements, did not talk much, to introduce the following methods:

  • Elements need to press the Add touchstart and touchend two events:
<div v-for="(item, index) in fileList" :key="index" @touchstart="touchstart(index,item)"  @touchend="touchend(index)">

    // Here are some of the elements of circulation

</div>
  • Add an event in the methods:
touchstart(index,item) {
    clearInterval (this.Loop); // clear the timer again, to prevent duplicate registration timer
    this.Loop = setTimeout(function() {
       
        // Here is the press after the event to be triggered

    } .Bind (this), 1000); // 1000 refers here requires a long press time in ms
},
touchend(index) {
    // This method is mainly used to each finger is removed after the timer is cleared
    clearInterval(this.Loop);
}

  Press events can be achieved by the above two steps.

 

Guess you like

Origin www.cnblogs.com/belongs-to-qinghua/p/12545384.html