js代码:

console.log("ontouchstart" in window);

 手机web浏览器,chrome模拟手机、手机APP会返回true,

pc端(非手机模拟状态下)返回false

 

 所以:一种事件的处理方法:


    var isTouch = ("ontouchstart" in window) ? true : false;
    var touchStartEvt = isTouch ? "touchstart" : "mousedown";
    var touchMoveEvt = isTouch ? "touchmove" : "mousemove";
    var touchEndEvt = isTouch ? "touchend" : "mouseup";
    var transitionEndEvt = vendorPrefix + "TransitionEnd";

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案