Komponenty to wielokrotnie użyteczne, samodzielne elementy interfejsu użytkownika. Props to sposób, w jaki rodzic przekazuje dane w dół do dziecka — są to wpisane, tylko do odczytu dane wejściowe dziecka.
Definiowanie props w dziecku
<!-- UserCard.vue -->
<script setup>
// declare props with types, requirements, and defaults
const props = defineProps({
name: { type: String, required: true },
age: { type: Number, default: 0 },
isAdmin: { type: Boolean, default: false },
});
</script>
<template>
<div class="card">
<h2>{{ name }}</h2> <!-- use props directly in the template -->
<p>Age: {{ age }}</p>
</div>
</template>
