我有一些功能可以防止设备上的触摸事件(在某些特定情况下)。它运行良好,直到最后一次更新 Chrome。
更新后,试图阻止我从中获得document或document.body不再工作的事件,但如果我从某个特定元素侦听事件,它会起作用。
例如:
//this not works
document.addEventListener("touchmove", function(event) {
event.preventDefault();
});
//this one works
document.querySelector(".container").addEventListener("touchmove", function(event) {
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
这不是很方便的行为,因为我在body元素中有很多子元素并且无法更改此结构。
有没有人知道如何让它再次工作,或者它是最新 Chrome 的正确行为?将不胜感激任何帮助,谢谢。