[Vuejs]-Detect exiting route changes in Vue

3👍

Vue lifecycle hook- BeforeDestroy is fired right before teardown. Your component will still be fully present and functional. If you need to cleanup events or reactive subscriptions,
beforeDestroy would probably be the time to do it.

<script>
export default {

  beforeDestroy() {
   //Try like this
    this.confirmDelete();
    console.log('item will be deleted');

  }
}
</script>

Ref – https://v2.vuejs.org/v2/api/#beforeDestroy

Leave a comment