Skip to content
Advertisement

How to remove event listener from Vue Component

I have a Vue2 component which contains an added eventListener i created on mounted. I was wondering how do i properly remove this listener when the component is destroyed?

JavaScript

Advertisement

Answer

You can use this.$el for whole component and destroy event like you created it:

JavaScript
JavaScript
JavaScript
Advertisement