微信H5模拟长按功能,碰到两个问题:
- click事件仍然会被触发
- input输入框无法输入
其中第二个问题是由于我引入了如下代码取消选中功能导致:
* {
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}其中,-webkit-user-select:none;会产生一些问题。
这是webkit内核浏览器下的一个bug,具体可以参考这篇文章:https://bugs.webkit.org/show_bug.cgi?id=82692
最终代码:
*:not(input, textarea) {
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
更多内容参考:https://www.cnblogs.com/mrnut/p/7656019.html
