[Vuejs]-Vue JS How to remove zombie event?

0๐Ÿ‘

โœ…

you need to remove the event when you remove the component:

<script>
  export default {
    methods: {
      go: function () {
        console.log('event received')
      }
    },
    created: function (){
        this.$parent.$on('go', this.go);
    },
    beforeDestroy: function (){
        this.$parent.$off('go',this.go);
    }
  }
<script>

0๐Ÿ‘

You have click method in created lifecycle hook, so it will get called whenever the children component will be rendered.

Leave a comment