Chapter 66: Vue $emit() Method

The $emit() method (in modern Vue 3 with <script setup> it’s usually just called emit())

This is the official, recommended way a child component tells its parent that “something happened”.

In Vue we follow a very clear direction rule (one of the first things you should burn into your brain):

  • Props go down → parent → child (data flows downward)
  • Events go up → child → parent (actions / notifications flow upward)

$emit() / emit() is how the child announces an event to the parent — and optionally sends data (payload) along with that announcement.

Without events, the child would have to directly mutate parent’s data (very bad — breaks reactivity rules and makes debugging hell).

With events → child stays dumb & reusable, parent stays in control.

Modern Vue 3 Way: defineEmits + emit() (what you should use in 2026)

In <script setup> we never use this.$emit anymore — we use:

TypeScript

Real, Complete Example – TodoItem that Emits Multiple Events

Child: TodoItem.vue

vue

Parent – listens to all emitted events

vue

Key Takeaways – emit() in 2026

Feature Old Options API Modern <script setup> Best Practice Tip
Declare events emits: [‘toggle’, ‘delete’] defineEmits<…>() Always use TypeScript types
Emit event this.$emit(‘toggle’, id) emit(‘toggle’, id) No this — much cleaner
With payload this.$emit(‘update’, id, value) emit(‘update’, id, newText) Any number of arguments
v-model support this.$emit(‘update:value’, val) emit(‘update:modelValue’, val) Enables v-model on component
Event name convention kebab-case (update:user) kebab-case in template, camel in JS Auto-converted
Multiple events emits: [‘click’, ‘focus’] defineEmits([‘click’, ‘focus’]) List all possible events

Quick Summary – When to Emit What

Child Action Typical Event Name Payload Example Parent Listens With
Checkbox toggled toggle / update:done id or { id, done } @toggle / @update:done
Item deleted delete / remove id @delete
Text edited update / update:text id, newText @update:text
Form submitted submit form data object @submit
Item selected (dropdown) select / update:value selected value / object @select / @update:value
Modal closed close / update:modelValue false @close / v-model

Pro Tips from Real Projects (Hyderabad 2026)

  • Always declare events with defineEmits — gives autocompletion & catches typos
  • Use kebab-case for event names in templates (@update:text)
  • For two-way binding → use update:propName pattern → enables v-model
  • Keep payloads small & serializable (numbers, strings, plain objects — avoid functions, DOM nodes)
  • Child should never mutate props — always emit → parent updates
  • In UI libraries → emit standard names: update:modelValue, close, confirm, cancel, select, change

Your mini homework:

  1. Create TodoItem.vue exactly as above
  2. Use it in parent with all three events
  3. Try to mutate a prop inside child → see Vue warning in console
  4. Add v-model:text support on TodoItem (emit update:text)

Any part confusing? Want full examples for:

  • Custom component with multiple v-model (v-model:title, v-model:body)?
  • Emit with complex payload (object, array)?
  • $emit in Options API for legacy code?
  • Events with TypeScript typing + validation?

Just tell me — we’ll build the next clean event-based component together 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *