Skip to content
移动端专属组件

Tabbar 底部标签栏

EwTabbar + EwTabbarItem 提供移动端一级导航:固定吸底(fixed)+ 全面屏安全区适配 + 等高占位(placeholder,防止脱离文档流后遮挡内容尾部)。页内内容切换由业务持有 v-model;页签未设 name 时以注册顺序索引为标识。fixed: false 可作为普通块级 标签栏内联使用(如卡片底部、演示壳内)。

基础用法

吸底标签栏 + 内容切换
fixed 模式吸底(真机自动适配安全区);v-model 驱动页内切换。演示壳内用 fixed=false 内联。
9:41
首页
精选内容与推荐位
vue
<script setup>
import { ref } from 'vue'

const tab = ref('home')
</script>

<template>
  <component :is="pages[tab]" />

  <!-- 真机:fixed 吸底 + 安全区适配 + 自动占位 -->
  <EwTabbar v-model="tab">
    <EwTabbarItem name="home" icon="home">首页</EwTabbarItem>
    <EwTabbarItem name="discover" icon="search" badge="5">发现</EwTabbarItem>
    <EwTabbarItem name="mine" icon="user">我的</EwTabbarItem>
  </EwTabbar>
</template>

图标与红点

页签图标用 icon 属性(EwIcon 注册名),需要区分选中态时用 #icon 插槽 (参数 active);dot 红点与 badge 角标都渲染在图标右上角,dot 优先。

icon 插槽 + dot/badge
#icon 插槽按 active 切换填充风格;「消息」红点常亮。
9:41
当前所在:feed
vue
<EwTabbar v-model="tab">
  <EwTabbarItem name="feed">
    <template #icon="{ active }">
      <EwIcon :name="active ? 'star-fill' : 'star'" :size="20" />
    </template>
    订阅
  </EwTabbarItem>
  <EwTabbarItem name="msg" icon="chat" dot>消息</EwTabbarItem>
  <EwTabbarItem name="me" icon="user" badge="New">我的</EwTabbarItem>
</EwTabbar>

API

EwTabbar

名称类型默认值说明
modelValuestring / number''当前激活项标识(v-model)
fixedbooleantrue吸底固定;false 时内联使用
placeholderbooleantruefixed 时渲染等高占位
borderbooleantrue顶部分隔线
safe-area-inset-bottombooleantrue适配全面屏底部安全区

EwTabbarItem

名称类型默认值说明
namestring / number''标识,缺省用注册顺序索引
iconstring''图标名(EwIcon 注册名)
dotbooleanfalse红点(优先于 badge)
badgestring / number''角标内容
disabledbooleanfalse禁用切换

事件与插槽

  • EwTabbar:change(value) / update:modelValue;无插槽。
  • EwTabbarItem:#icon 插槽参数 { active };默认插槽为文字标签。

基于 MIT 许可证发布