---
title: "ComponentEmits"
description: "ComponentEmits automatically extracts a Vue component's defineEmits definitions via nuxt-component-meta, generating an Emits documentation table in your Markdown that includes event names, parameter types, and descriptions, with no need to write event API documentation by hand. Use it together with ComponentProps and ComponentSlots."
canonical_url: "https://docs.mhaibaraai.cn/en/docs/components/component-emits"
---
# ComponentEmits

> ComponentEmits automatically extracts a Vue component's defineEmits definitions via nuxt-component-meta, generating an Emits documentation table in your Markdown that includes event names, parameter types, and descriptions, with no need to write event API documentation by hand. Use it together with ComponentProps and ComponentSlots.

## Usage

Use the `:component-emits` syntax in your Markdown documentation:

```vue
<template>
  <pre language=ts code=/**
   * Emitted events for the TestApi component
   */
  interface TestApiEmits {
    /**
     * 值变化时触发
     */
    change: (payload: [value: string]) => void;
    /**
     * 删除时触发
     */
    delete: (payload: []) => void;
  } />
  <template v-slot:code=>
  <pre className=language-mdc shiki shiki-themes material-theme-lighter material-theme material-theme-palenight code=:component-emits{slug="TestApi"}
   language=mdc meta= style=>
  <code __ignoreMap=>
  <span class=line>
  <span class=sMK4o>
  :</span>
  <span class=swJcz>
  component-emits</span>
  <span class=sMK4o>
  {</span>
  <span class=spNyl>
  slug</span>
  <span class=sMK4o>
  =</span>
  <span class=sMK4o>
  "</span>
  <span class=sfazB>
  TestApi</span>
  <span class=sMK4o>
  "</span>
  <span class=sMK4o>
  }
  </span></span></code></pre></template>
</template>
```

## API

### Props

```ts
/**
 * Props for the ComponentEmits component
 */
interface ComponentEmitsProps {
  /**
   * 获取组件事件的 slug 标识
   */
  slug?: string | undefined;
}
```

## Changelog

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

---

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


## Sitemap

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