--- name: component-events-emits description: Emit and handle custom events from child to parent components --- # Component Events Components emit custom events to communicate with parent components. ## Emitting Events Use `$emit` in templates or `defineEmits` in script: ```vue ``` ## Type-Based Declaration (Recommended) ```vue ``` ## Event Arguments Pass additional arguments to events: ```vue ``` Parent receives arguments: ```vue-html ``` ```ts function increaseCount(n: number) { count.value += n } ``` ## Event Validation Validate event payloads with object syntax: ```vue ``` ## Listening to Events Use `v-on` or `@` shorthand: ```vue-html ``` ## Event Name Casing - Emit in camelCase - Listen in kebab-case ```ts emit('someEvent') ``` ```vue-html ``` ## Important Notes - Component events do NOT bubble (unlike DOM events) - Only direct child events can be listened to - For sibling/deeply nested communication, use provide/inject or state management