Complete the code to emit an event named 'update' from the child component.
<template> <button @click="$emit('[1]')">Click me</button> </template>
The $emit method sends an event named 'update' from the child to the parent.
Complete the parent template to listen for the 'update' event from the child component.
<template> <ChildComponent @[1]="handleUpdate" /> </template>
The parent listens for the 'update' event emitted by the child using @update.
Fix the error in the child component to correctly emit the 'sendData' event with a payload.
<template> <button @click="$emit('[1]', message)">Send</button> </template> <script setup> const message = 'Hello!' </script>
Event names are case-sensitive. The correct event name is 'sendData' as emitted.
Fill both blanks to emit an event 'notify' with a payload 'info' from the child component.
<template> <button @click="$emit('[1]', [2])">Notify</button> </template>
The child emits the 'notify' event with the payload variable 'info'.
Fill all three blanks to create a child component that emits 'changeColor' with a color payload, and the parent listens and handles it.
<!-- ChildComponent.vue --> <template> <button @click="$emit('[1]', selectedColor)">Change Color</button> </template> <script setup> const selectedColor = 'blue' </script> <!-- ParentComponent.vue --> <template> <ChildComponent @[2]="[3]" /> </template>
The child emits 'changeColor'. The parent listens with @change-color (kebab-case) and calls handleColorChange.