页面正文
您页面的主要内容。
用法
PageBody组件包装您的主要内容并添加一些填充以保持一致的间距。
在PageHeader组件之后的Page组件的默认插槽中使用它:
<template>
<UPage>
<UPageHeader />
<UPageBody />
</UPage>
</template>
示例
虽然这些示例使用Nuxt Content,但这些组件可以与任何内容管理系统集成。
页面内
使用页面中的PageBody组件来显示页面的内容:
pages/[...slug].vue
<script setup lang="ts">
const route = useRoute()
definePageMeta({
layout: 'docs'
})
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('docs').path(route.path).first()
})
const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
return queryCollectionItemSurroundings('content', route.path)
})
</script>
<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />
<UPageBody>
<ContentRenderer :value="page" />
<USeparator />
<UContentSurround :surround="surround" />
</UPageBody>
<template #right>
<UContentToc :links="page.body.toc.links" />
</template>
</UPage>
</template>
在本例中,我们使用
@nuxt/content中的ContentRenderer组件来呈现页面内容。API
Props
| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
ui | { base?: any; } |
老虎机
| Slot | Type |
|---|---|
default | {} |
Theme
app.config.ts
export default defineAppConfig({
ui: {
pageBody: {
base: 'mt-8 pb-24 space-y-12'
}
}
})vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pageBody: {
base: 'mt-8 pb-24 space-y-12'
}
}
})
]
})Changelog
No recent changes