PageBodyPRO
页面的主要内容。
用法
PageBody 组件包裹你的主要内容,并添加一些内边距以保持一致的间距。
将其用在 Page 组件的默认插槽内,位于 PageHeader 组件之后。
<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('content').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>
在此示例中,我们使用了
ContentRenderer
组件(来自 @nuxt/content
)来渲染页面的内容。API
Props
Prop | 默认值 | 类型 |
---|---|---|
as |
|
此组件应渲染为的元素或组件。 |
插槽
插槽 | 类型 |
---|---|
default |
|
主题
app.config.ts
export default defineAppConfig({
uiPro: {
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({
uiPro: {
pageBody: {
base: 'mt-8 pb-24 space-y-12'
}
}
})
]
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import uiPro from '@nuxt/ui-pro/vite'
export default defineConfig({
plugins: [
vue(),
uiPro({
uiPro: {
pageBody: {
base: 'mt-8 pb-24 space-y-12'
}
}
})
]
})