简体   繁体   English

Cordova / Android点击/点击/ vclick / touchstart无法正常工作

[英]Cordova/Android on click/tap/vclick/touchstart not working

NOTE: The following issue only occurs on Android versions above 4.4.2 (as far as I know) 注意:以下问题仅发生在4.4.2以上的Android版本上(据我所知)


TL;DR buttons with click/tap/vclick/touchstart attached to them, seem to work only partly (10-30% of the time) in my cordova app (Android only). TL;带有click / tap / vclick / touchstart的DR按钮,在我的cordova应用程序中仅部分(10-30%的时间)工作(仅限Android)。


I'm trying to develop a hybrid app for ios/android/windows. 我正在尝试为ios / android / windows开发混合应用程序。 In the app, I'll have the occasional button that needs to trigger some actions. 在应用程序中,我偶尔会有触发某些操作的按钮。

Generally I'd use .on('click', function() { ... }); 通常我会使用.on('click', function() { ... }); , but I've learned that click doesn't really cooperate with mobile devices. ,但我了解到click并不真正与移动设备合作。

I tried changing click with vclick , tap and touchstart . 我尝试用vclicktaptouchstart更改click But nothing seems to trigger my click events. 但似乎什么都没有触发我的点击事件。

Next I tried to see if there was perhaps any css blocking my triggers, but nothing consistent. 接下来我试着看看是否有任何css阻止了我的触发器,但没有任何一致性。

The issue with this is, when I apply the following piece of code in my console, it would work sometimes (not always): 这个问题是,当我在我的控制台中应用以下代码时,它有时会工作(并不总是):

 $('.anyElement').on('tap', function(){ console.log("tapped"); }); 

I also tried the following, because I thought the binding was messed up somehow: 我也试过以下,因为我认为绑定是以某种方式搞砸了:

 $('.anyElement').off().on('tap', function(){ console.log("tapped"); }); 

So currently I'm kind of not sure where to look anymore. 所以目前我还不确定在哪里看。 If there perhaps are ways for me to figure out why my stuff doesn't get triggered, that'd be great! 如果有可能让我弄清楚为什么我的东西不会被触发,那就太好了!

was having the same issue on a cordova jquery app on intel xdk, what solved it for me, at least for now is commenting "fastclick.min.js" in my index.html. 在intel xdk上的cordova jquery应用程序上遇到了同样的问题,是什么解决了它,至少目前是在我的index.html中评论“fastclick.min.js”。 seems fastclick.min.js was the causing the issue on android, as it was working on IOS, check out http://community.phonegap.com/nitobi/topics/simple-js-events-like-onclick-are-not-working-on-devices he also soved it by removing some conflicted js, "smoothstate.js" in his case. 似乎fastclick.min.js是导致Android上的问题,因为它正在IOS上工作,请查看http://community.phonegap.com/nitobi/topics/simple-js-events-like-onclick-are-not在设备上工作时也通过删除一些冲突的js来解决它,在他的案例中使用“smoothstate.js”。 am still tryin to figure out a better fix though if it exists 如果它存在,我仍然试图找出一个更好的解决方案

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

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