Footer专业版
一个响应式的页脚组件。
用法
Footer 组件渲染一个 <footer>
元素。
使用 left
、default
和 right
插槽来自定义页脚。
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[] = [
{
label: 'Figma Kit',
to: 'https://www.figma.com/community/file/1288455405058138934',
target: '_blank'
},
{
label: 'Playground',
to: 'https://stackblitz.com/edit/nuxt-ui',
target: '_blank'
},
{
label: 'Roadmap',
to: '/roadmap'
},
{
label: 'Releases',
to: 'https://github.com/nuxt/ui/releases',
target: '_blank'
}
]
</script>
<template>
<UFooter>
<template #left>
<p class="text-muted text-sm">Copyright © {{ new Date().getFullYear() }}</p>
</template>
<UNavigationMenu :items="items" variant="link" />
<template #right>
<UButton
icon="i-simple-icons-discord"
color="neutral"
variant="ghost"
to="https://chat.nuxt.dev"
target="_blank"
aria-label="Discord"
/>
<UButton
icon="i-simple-icons-x"
color="neutral"
variant="ghost"
to="https://x.com/nuxt_js"
target="_blank"
aria-label="X"
/>
<UButton
icon="i-simple-icons-github"
color="neutral"
variant="ghost"
to="https://github.com/nuxt/nuxt"
target="_blank"
aria-label="GitHub"
/>
</template>
</UFooter>
</template>
在此示例中,我们使用 NavigationMenu 组件来渲染页脚居中的链接。
示例
app.vue
中 在
在你的 app.vue
文件或布局中使用 Footer 组件
app.vue
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[] = [{
label: 'Figma Kit',
to: 'https://www.figma.com/community/file/1288455405058138934',
target: '_blank'
}, {
label: 'Playground',
to: 'https://stackblitz.com/edit/nuxt-ui',
target: '_blank'
}, {
label: 'Roadmap',
to: '/roadmap'
}, {
label: 'Releases',
to: 'https://github.com/nuxt/ui/releases',
target: '_blank'
}]
</script>
<template>
<UApp>
<UHeader />
<UMain>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</UMain>
<USeparator icon="i-simple-icons-nuxtdotjs" type="dashed" class="h-px" />
<UFooter>
<template #left>
<p class="text-muted text-sm">
Copyright © {{ new Date().getFullYear() }}
</p>
</template>
<UNavigationMenu :items="items" variant="link" />
<template #right>
<UButton
icon="i-simple-icons-discord"
color="neutral"
variant="ghost"
to="https://chat.nuxt.dev"
target="_blank"
aria-label="Discord"
/>
<UButton
icon="i-simple-icons-x"
color="neutral"
variant="ghost"
to="https://x.com/nuxt_js"
target="_blank"
aria-label="X"
/>
<UButton
icon="i-simple-icons-github"
color="neutral"
variant="ghost"
to="https://github.com/nuxt/nuxt"
target="_blank"
aria-label="GitHub"
/>
</template>
</UFooter>
</UApp>
</template>
在此示例中,我们使用 Separator 组件在页脚上方添加一条边框。
API
属性
属性 | 默认值 | 类型 |
---|---|---|
as |
|
|
ui |
|
插槽
插槽 | 类型 |
---|---|
left |
|
default |
|
right |
|
top |
|
bottom |
|
主题
app.config.ts
export default defineAppConfig({
uiPro: {
footer: {
slots: {
root: '',
top: 'py-8 lg:py-12',
bottom: 'py-8 lg:py-12',
container: 'py-8 lg:py-4 lg:flex lg:items-center lg:justify-between lg:gap-x-3',
left: 'flex items-center justify-center lg:justify-start lg:flex-1 gap-x-1.5 mt-3 lg:mt-0 lg:order-1',
center: 'mt-3 lg:mt-0 lg:order-2 flex items-center justify-center',
right: 'lg:flex-1 flex items-center justify-center lg:justify-end gap-x-1.5 lg:order-3'
}
}
}
})
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: {
footer: {
slots: {
root: '',
top: 'py-8 lg:py-12',
bottom: 'py-8 lg:py-12',
container: 'py-8 lg:py-4 lg:flex lg:items-center lg:justify-between lg:gap-x-3',
left: 'flex items-center justify-center lg:justify-start lg:flex-1 gap-x-1.5 mt-3 lg:mt-0 lg:order-1',
center: 'mt-3 lg:mt-0 lg:order-2 flex items-center justify-center',
right: 'lg:flex-1 flex items-center justify-center lg:justify-end gap-x-1.5 lg:order-3'
}
}
}
})
]
})
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: {
footer: {
slots: {
root: '',
top: 'py-8 lg:py-12',
bottom: 'py-8 lg:py-12',
container: 'py-8 lg:py-4 lg:flex lg:items-center lg:justify-between lg:gap-x-3',
left: 'flex items-center justify-center lg:justify-start lg:flex-1 gap-x-1.5 mt-3 lg:mt-0 lg:order-1',
center: 'mt-3 lg:mt-0 lg:order-2 flex items-center justify-center',
right: 'lg:flex-1 flex items-center justify-center lg:justify-end gap-x-1.5 lg:order-3'
}
}
}
})
]
})