Skip to content

Vue Composition API: Lifecycle Events

Mike Lyttle edited this page May 11, 2023 · 3 revisions

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

Clone this wiki locally