ComponentSlots
: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.
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:
<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
ComponentProps
Generate a props table for a Vue component with a single `:component-props` line. Names, defaults, types and JSDoc descriptions come from nuxt-component-meta, so the docs stay in sync with the component.
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.