Passing data with props
A component that hard-codes its own text can only ever say one thing. To reuse it, a parent needs a way to hand it data.
Vue calls that data props. You declare the props a component accepts with
defineProps, then read them in the template like any other value:
<script setup>
defineProps(['label']);
</script>
<template>
<h1>Hello, {{ label }}!</h1>
</template>
A parent passes a prop as an attribute: <Greeting label="Vue" />. Vue matches
the attribute to the declared prop and makes its value available by name.
defineProps is a compiler macro, so you never import it.
Declaring the prop is what makes the component reusable: the same component renders different text for different parents. Without the declaration, the attribute is not a prop at all — Vue treats it as a stray attribute and passes it down to the root element instead of into your template.
The Test mounts your component with a label prop and checks the heading it
renders.
Challenge
The component always says the same thing. Make it accept data: export an App
component from App.vue that declares a label prop and renders it in a
level-one heading as Hello, {{ label }}!.
The Test mounts your component with label set to Vue and expects the heading
to read Hello, Vue!. The starter hard-codes a different greeting, so the Test
fails. Declare the prop and use it in the template.