المكونات هي أجزاء قابلة لإعادة الاستخدام ومكتفية بذاتها من واجهة المستخدم. الخصائص (Props) هي الطريقة التي ينقل بها الأب البيانات لأسفل إلى الابن — فهي مدخلات الابن المكتوبة وقراءة فقط.
تعريف الخصائص في الابن
<!-- 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>
