页面侧边栏
一个用于显示页面导航的固定侧边栏。
用法
PageAside 组件是一个粘性 <aside>
元素,仅从lg
断点.
将其用作 Page 组件的 left
或 right
插槽内
<template>
<UPage>
<template #left>
<UPageAside />
</template>
</UPage>
</template>
示例
尽管这些示例使用Nuxt Content,但这些组件可以与任何内容管理系统集成。
在布局中
在布局中使用 PageAside 组件来显示导航
layouts/docs.vue
<script setup lang="ts">
import type { ContentNavigationItem } from '@nuxt/content'
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
</script>
<template>
<UPage>
<template #left>
<UPageAside>
<UContentNavigation :navigation="navigation" />
</UPageAside>
</template>
<slot />
</UPage>
</template>
在此示例中,我们使用
ContentNavigation
组件来显示注入到 app.vue
中的导航。API
属性
属性 | 默认值 | 类型 |
---|---|---|
as |
|
此组件应渲染为的元素或组件。 |
ui |
|
插槽
插槽 | 类型 |
---|---|
top |
|
default |
|
bottom |
|
主题
app.config.ts
export default defineAppConfig({
ui: {
pageAside: {
slots: {
root: 'hidden overflow-y-auto lg:block lg:max-h-[calc(100vh-var(--ui-header-height))] lg:sticky lg:top-(--ui-header-height) py-8 lg:ps-4 lg:-ms-4 lg:pe-6.5',
container: 'relative',
top: 'sticky -top-8 -mt-8 pointer-events-none z-[1]',
topHeader: 'h-8 bg-default -mx-4 px-4',
topBody: 'bg-default relative pointer-events-auto flex flex-col -mx-4 px-4',
topFooter: 'h-8 bg-gradient-to-b from-default -mx-4 px-4'
}
}
}
})
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: {
pageAside: {
slots: {
root: 'hidden overflow-y-auto lg:block lg:max-h-[calc(100vh-var(--ui-header-height))] lg:sticky lg:top-(--ui-header-height) py-8 lg:ps-4 lg:-ms-4 lg:pe-6.5',
container: 'relative',
top: 'sticky -top-8 -mt-8 pointer-events-none z-[1]',
topHeader: 'h-8 bg-default -mx-4 px-4',
topBody: 'bg-default relative pointer-events-auto flex flex-col -mx-4 px-4',
topFooter: 'h-8 bg-gradient-to-b from-default -mx-4 px-4'
}
}
}
})
]
})
更新日志
5cb65
— 特性:导入 @nuxt/ui-pro
组件