ComponentSlots

List every slot of a Vue component with a single :component-slots line. Slot names, scoped parameter types and JSDoc descriptions come from the defineSlots type, so there is nothing to write by hand.

ComponentSlots reads a component's defineSlots type and renders each slot's name, scoped parameter type and description.

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

Usage

Slot Type
default{}

默认内容插槽

avatar{ src: string; }

头像插槽,作用域暴露头像地址

:component-slots{slug="TestApi"}

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

Documenting slots

Add JSDoc to every slot in defineSlots; the scoped parameter type is shown in the type column:

components/TestApi.vue
<script setup lang="ts">
defineSlots<{
  /**
   * Default content slot
   */
  default(props?: {}): any
  /**
   * Avatar slot, exposes the avatar URL
   * @see https://ui.nuxt.com/components/avatar
   */
  avatar(props: { src: string }): any
}>()
</script>

API

Props

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

获取组件插槽的 slug 标识

Changelog

No recent changes
Copyright © 2024 - 2026