Skip to content

Tabbar 底部导航

用于应用最底部的全局路由导航控件,支持基础贴底 (normal)、磨砂悬浮灵动浮岛 (island) 以及中间凸起缺口发布按钮 (raised) 3 种极奢视觉形态,全端自适应底栏安全区。


代码示例

1. 基础贴底导航 (Normal Mode)

标准 4 项贴底导航栏,包含图标与徽章角标。

vue
<template>
  <mu-tabbar v-model:current="active" :items="tabbarItems" @change="onChange" />
</template>

<script setup>
import { ref } from 'vue'

const active = ref(0)
const tabbarItems = ref([
  { text: '首页', icon: 'home' },
  { text: '分类', icon: 'grid' },
  { text: '消息', icon: 'bell', badge: '99+' },
  { text: '我的', icon: 'user' }
])

const onChange = (index) => {
  console.log('切换底部导航:', index)
}
</script>

2. 悬浮灵动浮岛胶囊 (Island Mode)

设置 mode="island",呈现带有圆角散焦阴影与毛玻璃的悬浮胶囊底栏。

vue
<template>
  <mu-tabbar
    v-model:current="active"
    :items="tabbarItems"
    mode="island"
    @change="onChange"
  />
</template>

3. 凸起中间缺口发布导航 (Raised Notch Mode)

设置 mode="raised",并在 items 的中间数据项配置 raised: true,自动生成弧形缺口与加号悬浮凸起按钮。

vue
<template>
  <mu-tabbar
    v-model:current="active"
    :items="raisedItems"
    mode="raised"
    raised-color="#6366F1"
    @change="onChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const active = ref(0)
const raisedItems = ref([
  { text: '首页', icon: 'home' },
  { text: '社区', icon: 'message-circle' },
  { text: '发布', icon: 'plus', raised: true }, // raised: true 设置为中间凸起按钮
  { text: '消息', icon: 'bell', badge: '3' },
  { text: '我的', icon: 'user' }
])
</script>

API 属性说明 (Props)

参数名说明类型可选值默认值
v-model:current / current当前激活选中的导航项索引Number-0
items导航项配置数组Array-[]
mode导航展现形态Stringnormal | island | raised'normal'
fixed是否固定悬浮在页面底端Booleantrue | falsetrue
background导航栏背景色String-''
activeColor激活态文字与图标高亮颜色String-''
raisedColor凸起缺口模式下中间大圆形按钮渐变色String-''

TabbarItem 配置属性 (Item Object)

参数名说明类型默认值
text导航项标签文字String''
icon矢量图标名称或图片 URLString''
selectedIcon激活选中时的专属矢量图标或图片 URLString''
badge红点徽章数字或文本Number | String-
dot是否显示为小红点Booleanfalse
raised是否设置为中间凸起缺口大按钮 (mode="raised" 时生效)Booleanfalse

事件说明 (Events)

事件名说明回调参数
change切换底部导航项时触发(index: Number)

基于 MIT 协议开源发行

H5 模拟器 (tabbar)☀️🔄