I have the following code to listen and remove the event. However, the event doesn't get removed:
window.addEventListener('mousemove', (event) => {
this.controlColumnWidth(event, startOffset, column)
})
window.removeEventListener('mouseup', this.controlColumnWidth)
How do I fix this?
You're mixing two different events here, mousemove
and mouseup
.
Also you need to make sure you remove the same (event) => { ... }
function instance that was originally registered:
const handler = event => {
this.controlColumnWidth(event, startOffset, column);
};
window.addEventListener('mousemove', handler);
window.removeEventListener('mousemove', handler);
// You can also store the handler on `this` if you need to remove
// the event in a different function (such as in the destroyed hook)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.