Vue · Junior · Question 30 of 75

How does a child notify its parent?

<script setup>
const emit = defineEmits(["save"]);
function onClick() { emit("save", { id: 1 }); }
</script>
<!-- parent: <Editor @save="handleSave" /> -->

Explanation

The parent listens with @save, and the payload becomes the handler argument. Unlike native DOM events, component events don't bubble.

Further reading

Problem with a question

Vue · Junior · question 30

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz