首页 > 技术文章 > vue.js 添加 fastclick的支持

zhaoyun4122 2019-05-06 11:31 原文

来源:https://www.cnblogs.com/amunamuna/p/8997533.html

当使用FastClick 时,input框在ios上点击输入调取手机自带输入键盘不灵敏,有时候甚至点不出来。而安卓上完全没问题。这个原因是因为FastClick的点击穿透。解决方法:

FastClick.prototype.onTouchEnd = function(event) {
if(event.target.hasAttribute("type") && event.target.getAttribute("type") == "text") {
event.preventDefault();   
return false;  
}
}

先执行安装fastclick的命令。

npm install fastclick -S

之后,在main.js中引入,并绑定到body。

import FastClick from 'fastclick'

FastClick.attach(document.body);        

推荐阅读