我想在 mouseup 事件触发时删除 mouseover 事件,但为什么不能 revomeEventListener 以及如何修复它,看来这是我在 javascript 中的弱点。
最佳答案
在您的 fnDown 中,您将事件监听器设置在 dragBox 上,但稍后您尝试将其从 dragArea 中删除。如果您打算从中删除监听器,则需要将监听器附加到 dragArea。此功能按预期工作。
Drag.prototype.fnDown = function (e) {
this.diff.x = e.clientX - this.dragBox.offsetLeft
this.diff.y = e.clientY - this.dragBox.offsetTop
this.dragArea.addEventListener('mousemove', this.fnMove,false)
}
关于javascript - 为什么不能删除EventListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41155537/