The Delightful World of Vue Part 2
Emitting up the Component Tree
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 1

Imagine we have a component that takes a value from the user and emits an event when the user changes it:

<template>
    <input
        :value="pizza.name"
        @input="updatePizzaName"
    />
</template>

<script>
export default {
    name: 'PizzaNameInput',
    props: {
        pizza: {
            type: Object,
            required: true,
        },
    },
    methods: {
        updatePizzaName($event) {
            this.$emit('update-pizza-name', { name: $event.target.value });
        },
    },
};
</script>

From its parent component, I want to re-emit this event so that I can handle it further up the component tree!

What is the best way of doing this?

Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.