One of my Vue2 components has a custom eventListener that I added in the mounted
lifecycle hook. I am now trying to figure out the correct way to remove this listener when the component is destroyed.
<template>
<div>
...
</div>
</template>
<script>
export default {
mounted() {
window.addEventListener('click', (evt) => {
this.handleClickEvent(evt)
})
},
destroyed() {
// window.removeEventListener('click', ????);
},
methods: {
handleClickEvent(evt) {
// do stuff with (evt)
},
},
}
</script>