Vue Composition API: Lifecycle Events - bcgov/healthgateway GitHub Wiki

Class Component

    created(): void {
        // perform actions after component is created
    }
    
    mounted(): void {
        // perform actions after component is mounted
    }

Composition API

import { onMounted } from "vue";
// perform actions after component is created

onMounted(() => {
    // perform actions after component is mounted
});

Notes

  • Actions performed in beforeCreate and created events should now be executed directly within <script setup>.
  • The beforeDestroy event has been renamed to beforeUnmount.
  • The destroyed event has been renamed to unmounted.

Documentation