手机浏览器下IScroll中click事件

产品的h5页面几乎都使用了iscroll插件,若是a标签在iscroll里,在部分手机浏览器中会出现没法点击的状况,无论是绑定click事件仍是使用a标签的href属性。href属性偶尔还会能点击,click事件彻底不能。浏览器

若是用button或input代替a,都能响应click事件。微信

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

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

 

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.ide

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

 这里说一般状况下你不须要额外配置iscroll,由于iscroll能默认选择最佳配置。spa

 

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).code

缘由就是这儿了,iscroll阻止了浏览器默认的行为,好比click。若是设置click为true,原来不能点击的手机能点击了,可是原来能点击的手机变成了双击,也就是将手机自己的click和iscroll的click各执行了一次。orm

若是只设置click为true,会出现部分a仍是没法点击,再加上taps:true;

 

感谢万能的stackoverflow, 

相关文章
相关标签/搜索