简体   繁体   English

Javascript触摸事件未被触发

[英]Javascript touch events are not getting triggered

I am running a hybrid app on an android device (Moto G5 plus/android 8). 我正在Android设备上运行混合应用程序(Moto G5 plus / android 8)。 The touch events are not working on it. 触摸事件不起作用。 The same app when installed on other android devices(Android 6/7/8/9) works just fine. 安装在其他Android设备(Android 6/7/8/9)上的相同应用程序工作得很好。

I tried all the touch events(touchstart, touchmove, touchend, touchcancel), none of them work. 我尝试了所有触摸事件(touchstart,touchmove,touchend,touchcancel),但没有一个能够正常工作。 I have also tried with event.preventDefault() method, didn't work. 我也试过了event.preventDefault()方法,没用。

I am debugging this android app on chrome DevTools. 我在chrome DevTools上调试这个Android应用程序。

Even a simple touch event listener as this one doesn't work on it: 即使是一个简单的触摸事件监听器,因为它不适用于它:

document.addEventListener("touchstart", function(){
 alert("touch started");
});

I have tried a lot of stuff but nothing seems to be helping. 我尝试了很多东西,但似乎没有任何帮助。 kindly let me know if you have come across a similar issue. 如果您遇到类似的问题,请告诉我。 Please help. 请帮忙。 Thanks. 谢谢。

try this : 尝试这个 :

 document.addEventListener("touchstart", function(ev){ ev.preventDefault(); alert("touch started"); },false); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM