[Vuejs]-RemoveEventListener doesn't work in Javascript

3👍

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)

Leave a comment