在 jQuery mobile 中,tap 和 vclick 之间的区别是什么? [英] In jQuery mobile, what's the diff between tap and vclick?

查看:14
本文介绍了在 jQuery mobile 中,tap 和 vclick 之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用哪个事件来收听?为什么要使用 vclick?而我就是不知道在哪种情况下使用哪种.

which event should i use to listen to ? why use vclick? and I just don't know which situation to use which.

推荐答案

如果 jQuery Mobile Tap 过去只能在移动设备上工作.现在不是这种情况了.

In case of jQuery Mobile Tap used to work only on mobile devices. This is not case any more.

创建 VClick 是为了弥补桌面/移动设备之间点击/点击不兼容之间的差距.

VClick was created to bridge a gap between click/tap incompatibility among desktop/mobile devices.

现在您可以随意使用水龙头,但几乎没有问题.在 iOS 平台上点击会失败.应改用 Touchstart.

Now days you case freely use tap but there are few problems. Tap will fail on iOS platform. Touchstart should be used instead.

示例:

适用于台式机和移动设备.

Will work both on desktop and mobile devices.

  • Android 4.1.1 - 无延迟
  • iOS - 无延迟
  • 桌面版 Firefox 19 &Chrome 25.0.1364.152 - 无延迟

http://jsfiddle.net/Gajotres/PYPXu/embedded/result/

$(document).on('pagebeforeshow', '#index', function(){       
    $( document ).on( "vclick", '[data-role="page"]', function() {
        $( this ).append( "<span style='color:#00F;'>vmouseup fired.</span>" );
    });
});

点击:

它曾经只适用于移动设备,现在也适用于桌面浏览器,但在 jQuery Mobile 1.1 及以下版本的 iOS 上会失败.

It used to work only on a mobile devices, now works also on a desktop browsers, but will fail on a iOS with a jQuery Mobile version 1.1 and below.

  • Android 4.1.1 - 无延迟
  • iOS - 无延迟
  • 桌面版 Firefox 19 &Chrome 25.0.1364.152 - 无延迟

http://jsfiddle.net/Gajotres/k8kSA/

$(document).on('pagebeforeshow', '#index', function(){       
    $( document ).on( "tap", '[data-role="page"]', function() {
        $( this ).append( "<span style='color:#00F;'>tap fired.</span>" );
    });
});

点击

适用于移动设备和桌面浏览器.

Click

Will work on mobile devices and desktop browsers.

  • Android 4.1.1 - 可见延迟(300+ 毫秒)
  • iOS - 无延迟
  • 桌面版 Firefox 19 &Chrome 25.0.1364.152 - 无延迟

http://jsfiddle.net/Gajotres/L2FHp/

$(document).on('pagebeforeshow', '#index', function(){       
    $( document ).on( "click", '[data-role="page"]', function() {
        $( this ).append( "<span style='color:#00F;'>click fired.</span>" );
    });
});

结论

如果您希望使用 VClick 向后兼容 jQM,请在任何其他情况下使用 Tap.

Conclusion

If you want a backward jQM compatibility stick with VClick, in any other case use Tap.

这篇关于在 jQuery mobile 中,tap 和 vclick 之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆