The Delightful World of Vue Part 2
More Mixin Magic
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 2 / 2

Say I have this very simple counter component:

<template>
    <div v-text="count" />
</template>

<script>
export default {
    name: 'CounterComponent',
    data() {
        return {
            count: 0,
        };
    },
};
</script>

Why is it important that data is a function that returns an object? Why can't data be set directly to the { count: 0 } object?

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.