简体   繁体   English

HTML5 Canvas - 删除事件监听器

[英]HTML5 Canvas - deleting event listener

If I want to save on memory, does an event listener need to be deleted from an element if the element is already deleted.如果我想保存 memory,如果元素已被删除,是否需要从元素中删除事件侦听器。 If I do something like this:如果我做这样的事情:

temp_canvas = document.createElement('canvas');
temp_canvas.id = 'temp_canv';

$("#temp_canv").mousedown(e => {this.line_down(e);});

document.getElementById("temp_canv").removeEventListener('mousedown', line_down(e));

Does this remove the memory of the event listener along with the canvas element?这是否会删除事件侦听器的 memory 以及 canvas 元素?

Thanks谢谢

They only stay in memory if there are references to said element.如果有对所述元素的引用,它们只会留在 memory 中。 See this answer .看到这个答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM