Vue 3 & Composition API
16 mins read
Free Lesson
Pass data down with defineProps() and emit custom events up to parent containers with defineEmits().
Component Props & Emits
<!-- ChildComponent.vue -->
<script setup>
const props = defineProps({
title: { type: String, required: true },
isFree: { type: Boolean, default: true }
})
const emit = defineEmits(['start-lesson'])
</script>
<template>
<div class="lesson-item">
<h3>{{ title }}</h3>
<button @click="emit('start-lesson', title)">Start</button>
</div>
</template>