கூறுகள் மீண்டும் பயன்படுத்தக்கூடிய, சுயாதீனமான UI துண்டுகள். Props என்பது பெற்றோர் கூறு குழந்தைக்கு தரவை கீழே அனுப்பும் முறை — இவை குழந்தையின் வகை, வாசிப்பு மட்டுமே உள்ளீடுகள்.
குழந்தை கூறில் 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>
