我正在使用的库(famo.us)将事件侦听器插入到中断滚动视图的窗口中。由于各种管道原因,很难修改库,所以有没有办法删除其他代码添加的事件监听器?
我的理解是,在调用 remove 调用时我也需要访问实际的函数定义。
我尝试如下,获取处理程序引用,然后将其删除,但没有运气。
> getEventListeners(window).touchmove
[
Object
listener: function (event) {
remove: function ()
type: "touchmove"
useCapture: true
__proto__: Object
]
> f=getEventListeners(window).touchmove
[
Object
]
> window.removeEventListener('touchmove', f)
undefined
> getEventListeners(window)
Object {message: Array[1], load: Array[2], unload: Array[1], online: Array[1], resize: Array[1]…}
load: Array[2]
message: Array[1]
online: Array[1]
popstate: Array[1]
resize: Array[1]
touchmove: Array[1] <<< bugger is still there!
unload: Array[1]