Closed gera2ld closed 8 years ago
https://github.com/vuejs/vue/blob/dev/src/instance/internal/events.js#L178
this.$on('hook:destroyed')
should work.
@LinusBorg Thanks, this is exactly what I was looking for. Is it safe to use it in the future since it's not documented?
it works the same way in 2.0, and I'Äm not aware of any plans to change that behaviour anytime.
I want to add a
destroyed
hook for a component instance, butthis.destroyed
seems not to work since it should be defined in the constructor. I could not find any related events to be listened in the document. I thought there would be something likethis.$on('destroyed')
but could not find any. So what is the right way to add lifecycle hooks on the fly?