Props — Vue

Menerima Props // Di komponen child, gunakan defineProps const props = defineProps(["title", "count"]) ---template--- {{ title }} {{ count }} Props dengan Tipe

Menerima Props

// Di komponen child, gunakan defineProps
const props = defineProps(["title", "count"])

---template---
<div>
  <h3>{{ title }}</h3>
  <span>{{ count }}</span>
</div>

Props dengan Tipe

defineProps({
  title: String,
  count: { type: Number, default: 0 },
  items: { type: Array, required: true },
})

Props Bersifat Read-Only

Jangan pernah mengubah props di komponen child. Jika perlu mengubah, gunakan emit ke parent.

Yang akan kamu pelajari