【发布时间】:2019-04-18 10:18:40
【问题描述】:
我试图阻止默认的滚动行为。
$(window).on('mousewheel DOMMouseScroll', wheel);
function wheel(e) {
e.preventDefault()
}
这导致了这个错误:
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL>
当然。我找到了thesequestions 并添加了他们的解决方案。
$(window).on('mousewheel DOMMouseScroll', wheel, {passive:false});
但是现在我收到以下错误:
Uncaught TypeError: ((p.event.special[l.origType] || {}).handle || l.handler).apply is not a function
at dispatch (0dfbbab736b8.js:formatted:1850)
at h (0dfbbab736b8.js:formatted:1685)
The only related question I could find 只是告诉我删除{passive:false},这意味着我又回到了原来的问题上。
我做错了什么?如何防止此处出现默认行为?
【问题讨论】:
标签: javascript dom-events