The Delightful World of Vue
Where should a Piece of Data Live?
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 1

Let's say you have a component with a prop named firstName and you change it inside that component using a method like so:

<template>
    <span>{{ name }}</span>
    <button @click="changeFirstName">Change First Name</button>
</template>

<script>
export default {
    name: 'NameComponent',
    props: ['firstName', 'lastName'],
    computed: {
        name() {
            return this.firstName + ' ' + this.lastName;
        }
    },
    methods: {
        changeFirstName() {
            this.firstName = 'Beckett';
        },
    },
};
</script>

What is wrong with this code?

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.