Complete the code to run a function when the component is mounted.
<script setup> import { [1] } from 'vue' [1](() => { console.log('Component mounted') }) </script>
The onMounted hook runs a function after the component is inserted into the DOM.
Complete the code to run cleanup code when the component is about to be removed.
<script setup> import { onBefore[1] } from 'vue' onBefore[1](() => { console.log('Cleanup before component unmounts') }) </script>
The onBeforeUnmount hook runs just before the component is removed from the DOM, perfect for cleanup.
Fix the error in the code to run code when the component updates.
<script setup> import { on[1] } from 'vue' on[1](() => { console.log('Component updated') }) </script>
The onUpdated hook runs after the component has updated and the DOM has been re-rendered.
Fill both blanks to run code before the component updates and after it updates.
<script setup> import { onBefore[1], on[2] } from 'vue' onBefore[1](() => { console.log('Before update') }) on[2](() => { console.log('After update') }) </script>
onBeforeUpdate runs before the component updates, and onUpdated runs after the update.
Fill all three blanks to run code when the component is mounted, before unmount, and after update.
<script setup> import { [1], onBefore[2], on[3] } from 'vue' [1](() => { console.log('Mounted') }) onBefore[2](() => { console.log('Before unmount') }) on[3](() => { console.log('Updated') }) </script>
Import onMounted, then use onBeforeUnmount and onUpdated hooks for the respective lifecycle events.