ios点击时反应存在延时,导致点击感觉慢,用户体验不好
以下方式处理该问题:
//记载fastclick
loadFastClick("./js/fastclick.js", function () {
FastClick.attach(document.body);
});
/**
* 动态加载JS
* @param {string} url 脚本地址
* @param {function} callback 回调函数
*/
function loadFastClick(url, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
if(typeof(callback)=='function'){
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
callback();
script.onload = script.onreadystatechange = null;
}
};
}
head.appendChild(script);
}
fastclick地址:https://download.csdn.net/download/tjj3027/10895914