Passing Data with Props
Veeg om het menu te tonen
Components often need to receive data from their parent. In Vue, this is done using props.
Props allow you to pass values into a component as attributes.
<!-- Message.vue -->
<script setup>
defineProps(["text"]);
</script>
<template>
<p>{{ text }}</p>
</template>
Here, the component expects a text prop.
You can pass data to this component from a parent.
<script setup>
import Message from "./components/Message.vue";
</script>
<template>
<Message text="Hello from parent" />
</template>
The value is passed into the component and displayed in the template.
Props help you create reusable components that can display different data depending on how they are used.
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 1. Hoofdstuk 11
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Sectie 1. Hoofdstuk 11