---
title: "ComponentEmits"
description: "Use `:component-emits` to list event names, parameters, and descriptions from `defineEmits`."
canonical_url: "https://docs.mhaibaraai.me/en/docs/components/component-emits"
---
# ComponentEmits

> Use \`:component-emits\` to list event names, parameters, and descriptions from \`defineEmits\`.

`ComponentEmits` reads a component's `defineEmits` type and renders each event's name, parameter signature and description.

> [!NOTE]
> See: /en/docs/components/component-props
> 
> Requires 
> 
> movkNuxtDocs.componentDocs
> 
> , with the same prerequisites as 
> 
> ComponentProps
> 
> .

## Usage

```mdc
:component-emits{slug="TestApi"}
```

Without `slug`, the component is resolved from the last segment of the current route.

## Documenting events

Declare events with the named tuple syntax and add JSDoc to each one. At build time the layer parses these comments from the source to fill in the event descriptions that `vue-component-meta` cannot read:

```vue [components/TestApi.vue]
<script setup lang="ts">
defineEmits<{
  /**
   * Emitted when the value changes
   * @see https://vuejs.org/guide/components/events.html
   */
  change: [value: string]
  /**
   * Emitted on delete
   */
  delete: []
}>()
</script>
```

## API

### Props

```ts
/**
 * Props for the ComponentEmits component
 */
interface ComponentEmitsProps {
  /**
   * 获取组件事件的 slug 标识
   * @default 路由路径的最后一段
   */
  slug?: string | undefined;
}
```

## Changelog

See commit history for [layer/modules/component-docs/runtime/components/ComponentEmits.vue](https://github.com/mhaibaraai/movk-nuxt-docs/commits/main/layer/modules/component-docs/runtime/components/ComponentEmits.vue).

---

- [GitHub](https://github.com/mhaibaraai/movk-nuxt-docs/blob/main/layer/modules/component-docs/runtime/components/ComponentEmits.vue)


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.me/sitemap.md) for all pages.
