gpt4 book ai didi

Android webview touchmove错误

转载 作者:行者123 更新时间:2023-11-29 16:30:28 33 4
gpt4 key购买 nike

我正在开发一个 Android WebView 应用程序,由于某种原因,“touchmove”事件拒绝触发。它在桌面浏览器上运行良好。我该如何解决?也不适用于 android 模拟器。

document.body.addEventListener("touchstart", function (e) {
console.log("touchstart", e);
e.preventDefault();
e.stopPropagation();
});
document.body.addEventListener("touchmove", function (e) {
console.log("touchmove", e); // <--- refuses to fire
e.preventDefault();
e.stopPropagation();
});
document.body.addEventListener("touchend", function (e) {
console.log("touchend", e);
e.preventDefault();
e.stopPropagation();
});

最佳答案

您可能需要像这样解决它:

var onTouchEnd = function(){
console.log("touch end");
}
document.addEventListener("touchstart", onTouchEnd);
document.addEventListener("touchmove", onTouchEnd);
document.addEventListener("touchend", onTouchEnd);

试着这样安慰它

var onTouchEnd = function(){
console.log("touch end");
var touch = event.changeTouches[0];
console.log("touch", touch);
}
document.addEventListener("touchstart", onTouchEnd);
document.addEventListener("touchmove", onTouchEnd);
document.addEventListener("touchend", onTouchEnd);

关于Android webview touchmove错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56485626/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com