【问题标题】:Android webview touchmove bugAndroid webview touchmove 错误
【发布时间】:2019-06-06 22:01:27
【问题描述】:

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

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();
});

【问题讨论】:

    标签: android webview touch-event


    【解决方案1】:

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

    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);
    

    【讨论】:

    • 嗯,不,我需要触发 touchmove 事件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    • 2013-08-27
    • 2017-07-15
    • 2013-10-10
    • 1970-01-01
    相关资源
    最近更新 更多