[Vuejs]-Why lifecycle callback does not get called?

0👍

If you want to use the Composition API, you need to add ‘setup’ to the ‘script’ tag, for example:

<script setup>

import { onMounted } from 'vue'

// lifecycle hooks
onMounted(() => {
  console.log('onMounted')
})

</script>

Here is the official documentation.

Additionally, I recommend creating a Vue template using Vite.

Leave a comment