ਇੱਕ ਬਾਲ ਆਪਣੇ ਮਾਤਾ-ਪਿਤਾ ਤਕ ਈਵੈਂਟਸ ਭੇਜ ਕੇ ऊপर ਬਾਤ ਕਰਦਾ ਹੈ। ਮਾਤਾ-ਪਿਤਾ @event-name ਦੇ ਨਾਲ ਉਹਨਾਂ ਦੀ ਸੁਣਦੇ ਹਨ। ਇਹ Vue ਦਾ ਇੱਕ-ਤਰਫਾ ਡੇਟਾ ਪ্রবাह ਪੂਰਾ ਕਰਦਾ ਹੈ: props ਹੇਠਾਂ, ਈਵੈਂਟਸ ऊपर।
ਬਾਲ ਤੋਂ ਈਵੈਂਟ ਭੇਜਣਾ
<!-- TodoItem.vue -->
<script setup>
const props = defineProps({ todo: Object });
const emit = defineEmits(["delete", "toggle"]); // declare the events you emit
function onDelete() {
emit("delete", props.todo.id); // emit an event WITH a payload
}
</script>
<template>
<li>
{{ todo.text }}
<button @click="onDelete">Delete</button>
<button @click="emit('toggle', todo.id)">Toggle</button>
</li>
</template>
