Skip to content

Tabbar 底部导航栏

底部主导航栏。支持 2-5 标签切换、中央凸起按钮、Badge/Dot 徽标、路由模式、安全区适配。

基础用法

vue
<template>
  <see-tabbar v-model="activeTab" :tabs="tabs" />
</template>

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

const activeTab = ref('home')
const tabs = [
  { name: 'home', text: '首页', icon: '🏠' },
  { name: 'category', text: '分类', icon: '📂' },
  { name: 'cart', text: '购物车', icon: '🛒' },
  { name: 'mine', text: '我的', icon: '👤' }
]
</script>

Badge/Dot 徽标

vue
<template>
  <see-tabbar v-model="activeTab" :tabs="tabs" />
</template>

<script setup>
const tabs = [
  { name: 'home', text: '首页', icon: '🏠' },
  { name: 'msg', text: '消息', icon: '💬', badge: 99 },
  { name: 'cart', text: '购物车', icon: '🛒', dot: true }
]
</script>

中央凸起按钮

vue
<template>
  <see-tabbar v-model="activeTab" :tabs="tabs" @on-center-click="onCenterClick" />
</template>

<script setup>
const tabs = [
  { name: 'home', text: '首页', icon: '🏠' },
  { name: 'publish', text: '发布', icon: '➕', isCenter: true, centerIcon: '✚' },
  { name: 'mine', text: '我的', icon: '👤' }
]

const onCenterClick = () => {
  uni.navigateTo({ url: '/pages/publish/index' })
}
</script>

TabbarItem

属性类型说明
namestring | number唯一标识
textstring显示文字
iconstring图标名称
activeIconstring选中时图标名称
badgestring | number徽标内容
dotboolean是否显示红点
isDisabledboolean是否禁用
urlstring路由模式下的页面路径
isCenterboolean是否为中央凸起按钮
centerIconstring中央按钮图标

Props

属性类型默认值说明
modelValuestring | number''当前选中的 tab name
tabsTabbarItem[][]tab 列表
isFixedbooleantrue是否固定在底部
isFrostedbooleanfalse是否启用毛玻璃效果
zIndexnumber990层级
safeAreaInsetBottombooleantrue是否适配底部安全区
activeColorstring''选中时颜色
inactiveColorstring''未选中时颜色
bgColorstring''自定义背景色
borderbooleantrue是否显示顶部边框
routebooleanfalse是否为路由模式
placeholderbooleantruefixed 定位时是否生成占位元素

Events

事件名参数说明
onChangename, indextab 切换
onClickname, indextab 点击(切换前触发)
onCenterClick-中央按钮点击
update:modelValuevaluev-model 更新

Expose

方法名参数说明
switchTabname切换 tab
setBadgename, badge设置徽标
clearBadgename清除徽标

辽 ICP 备 2025070134 号