ရိုးရိုးလေး ရှင်းပြမယ်
Props သည် parent မှ child သို့ one-way data flow ဖြစ်သည်။ Child က prop ကိုတိုက်ရိုက်မပြောင်းဘဲ ပြောင်းလဲလိုပါက event emit လုပ်ရမည်။ Type, required နှင့် default validation များဖြင့် component contract ကိုရှင်းလင်းစေပါ။
vue
<!-- ProductCard.vue -->
<script setup>
const props = defineProps({
title: { type: String, required: true },
price: { type: Number, default: 0 }
})
</script>
<template>
<article>
<h3>{{ props.title }}</h3>
<p>{{ props.price.toLocaleString() }} MMK</p>
</article>
</template>You should see
Vue Handbook
18,000 MMKလက်တွေ့စမ်းကြည့်ရန်
UserBadge component ကို name, role နှင့် online Boolean props များဖြင့် တည်ဆောက်ပါ။
Props — Vue.js