vue.js 使用 fastclick解決移動端click事件300毫秒延遲方法


一.使用npm安裝:

npm install fastclick -S
二.用法:

安裝完以后,可以在在main.js中全局引入,並綁定到body,全局生效。或者在單頁面引入,只針對當前頁面生效

   
//引入
    import FastClick from 'fastclick'
    //初始化FastClick實例。在頁面的DOM文檔加載完成后
    FastClick.attach(document.body)

 



三.使用過程中存在的bug:
FastClick.prototype.onTouchEnd = function(event) {
                if(event.target.hasAttribute("type") && event.target.getAttribute("type") == "text") {
                    event.preventDefault();   
                    return false;  
                }
            }

 



免責聲明!

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



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