A plugin call removeEventListener automatically when a VueInstance has been destroyed.
You can install vue-add-event-listener using npm or by downloading the minified build on GitHub.
npm install vue-add-event-listener
Then import the plugin in your application entry point (typically main.js if you used vue-cli to scaffold your project) and tell Vue to use it.
In component, you can use
this.$listen instead of
addEventListener. You don't need to call
removeEventListener, when a instance has been destroyed.
this// ==> target.addEventLister(type, listener, options)