ComponentEmits

List every event of a Vue component with a single :component-emits line. Event names, parameter signatures and JSDoc descriptions come from the defineEmits type and complete the API docs next to the props and slots tables.

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

Requires movkNuxtDocs.componentDocs, with the same prerequisites as ComponentProps.

Usage

Event Type
change[value: string]
(event: "change", value: string): void

值变化时触发

delete[]
(event: "delete"): void

删除时触发

: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:

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

Prop Default Type
slug路由路径的最后一段 string

获取组件事件的 slug 标识

Changelog

No recent changes
Copyright © 2024 - 2026