获取 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>
<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>
fetchComponentMeta(name)获取组件元数据。
586a5 — ✨ feat: 添加 Nuxt 文档主题 layer 核心代码