[轉]手機瀏覽器下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.

 

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就ok了。不要問我為什么阻止了默認click之后,有的手機瀏覽器可以,有的不可以,這個我也不知道。- -。

如果只設置click為true,會出現部分a還是無法點擊,再加上taps:true;

Set this to true to let iScroll emit a custom tap event when the scroll area is clicked/tapped but not scrolled.

 

感謝萬能的stackoverflow


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM