fetchComponentMeta

获取 Vue 组件元数据的函数。

概述

获取 Vue 组件的元数据,包括 Props、Emits、Slots 等信息。

<script setup lang="ts">
const { meta } = await fetchComponentMeta('UButton')

console.log(meta.props)   // Props 定义
console.log(meta.emits)   // Events 定义
console.log(meta.slots)   // Slots 定义
</script>

显示 Props 文档

<template>
  <div>
    <h2>Props</h2>
    <ul>
      <li v-for="prop in meta.props" :key="prop.name">
        <code>{{ prop.name }}</code>: {{ prop.type }}
        <p v-if="prop.description">{{ prop.description }}</p>
      </li>
    </ul>
  </div>
</template>

<script setup lang="ts">
const { meta } = await fetchComponentMeta('UButton')
</script>

API

fetchComponentMeta(name)

获取组件元数据。

参数

name
string required
组件名称(PascalCase)。

Changelog

586a5 — ✨ feat: 添加 Nuxt 文档主题 layer 核心代码

Copyright © 2024 - 2026