手机浏览器下IScroll中click事件

产品的h5页面几乎都使用了iscroll插件,如果a标签在iscroll里,在部分手机浏览器中会出现无法点击的情况,不管是绑定click事件还是使用a标签的href属性。href属性偶尔还会能点击,click事件完全不能。

如果用button或input代替a,都能响应click事件。

如果用微信内置浏览器,都能响应click事件(nubia除外)。QQ浏览器也能响应。

也就是出现此问题跟手机本地浏览器,iscroll,a标签都有关系。

 

iScroll uses various techniques to scroll based on device/browser capability. Normally you don't need to configure the engine, iScroll is smart enough to pick the best for you.

Nonetheless it is important to understand which mechanisms iScroll works on and how to configure them.

 这里说通常情况下你不需要额外配置iscroll,因为iscroll能默认选择最佳配置。

 

options太多,直接看重点,click和tap

To override the native scrolling iScroll has to inhibit some default browser behaviors, such as mouse clicks. If you want your application to respond to the click event you have to explicitly set this option to true. Please note that it is suggested to use the custom tap event instead (see below).

原因就是这儿了,iscroll阻止了浏览器默认的行为,比如click。如果设置click为true,原来不能点击的手机能点击了,但是原来能点击的手机变成了双击,也就是将手机本身的click和iscroll的click各执行了一次。

如果只设置click为true,会出现部分a还是无法点击,再加上taps:true;

 

感谢万能的stackoverflow, 

 

转载于:https://www.cnblogs.com/alexandra/p/3968457.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值