Complete the code to run a function when the component is first shown.
<script setup> import { [1] } from 'vue' [1](() => { console.log('Component is mounted') }) </script>
The onMounted function runs code when the component appears on screen.
Complete the code to run cleanup code when the component is removed.
<script setup> import { [1] } from 'vue' [1](() => { console.log('Component is unmounted') }) </script>
The onUnmounted function runs code when the component is removed from the page, useful for cleanup.
Fix the error in the code to properly log when the component mounts.
<script setup> import { onMounted } from 'vue' onMounted(() => { console.log('Mounted at: ' + [1]) }) </script>
Using new Date() creates a date object representing the current time, which can be logged.
Fill both blanks to log messages when the component mounts and unmounts.
<script setup> import { [1], [2] } from 'vue' [1](() => { console.log('Mounted') }) [2](() => { console.log('Unmounted') }) </script>
onMounted runs code when the component appears, and onUnmounted runs code when it disappears.
Fill all three blanks to import lifecycle hooks and use them to log mount and unmount events.
<script setup> import { [1], [2] } from 'vue' [1](() => { console.log('Component mounted') }) [2](() => { console.log('Component unmounted') }) const message = 'Hello Vue' console.log([3]) </script>
We import onMounted and onUnmounted to run code at lifecycle events. The variable message is logged last.