双击事件 如何判断

if (this.firstClick) {
    
    
  this.secondClick = new Date().getTime();
  if (this.secondClick - this.firstClick < 500) {
    
    
    this.firstClick = null;
    this.secondClick = null;
    console.log("双击触发了");
  } else {
    
    
    this.firstClick = new Date().getTime();
    console.log("间隔太长");
  }
} else {
    
    
  this.firstClick = new Date().getTime();
  console.log("最初的点击");
}

猜你喜欢

转载自blog.csdn.net/m0_54944506/article/details/128257563