蔡繁荣
蔡繁荣
  • 发布:2015-07-28 16:51
  • 更新:2015-07-28 17:31
  • 阅读:2776

【报Bug】touchend 事件监听不到,部分机型安卓

分类:HTML5+

机型:红米、华为等。

document.querySelector('.container').addEventListener('touchstart', function(){  
      console.log('touchstart: is_touch true');  
      is_touch = true;  
}, false);  
document.querySelector('.container').addEventListener('touchend', function(){  
      console.log('touchend: is_touch false');  
      is_touch = false;  
}, false);   
document.querySelector('.container').addEventListener('touchcancel', function(){  
     console.log('touchcancel: is_touch false');  
     is_touch = false;  
}, false);

滑动过程,控制台输出:

touchstart: is_touch true at js/common.js:400  
touchcancel: is_touch false at js/common.js:408
2015-07-28 16:51 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

在默认浏览器里测试是否一样。

touchstart,touchend,touchcancel,touchmove这是底层提供的事件,

  • 蔡繁荣 (作者)

    如果是底层的问题,那要怎么办呢?

    2015-07-28 21:57

  • 蔡繁荣 (作者)

    网上有看到很多遇到这个问题的,有些Android没有触发touchend 事件

    2015-07-29 00:47

  • DCloud_UNI_FXY

    回复 蔡繁荣:把touchcancel当成touchend来使用。也就是说,如果你直接用底层事件,可以把你touchend要处理的逻辑,同时放在touchend和touchcancel里边。

    2015-07-29 01:45

该问题目前已经被锁定, 无法添加新回复