Skip to content

Tabbar 标签栏

介绍

底部导航栏,用于在不同页面之间进行切换、展示操作按钮。

基础用法

通过 v-model 控制当前选中的标签索引。

html
<vd-tabbar v-model="active">
  <vd-tabbar-item title="首页" icon="home" />
  <vd-tabbar-item title="消息" icon="msg" />
  <vd-tabbar-item title="购物车" icon="cart" />
  <vd-tabbar-item title="我的" icon="user" />
</vd-tabbar>
ts
const active = ref(0);

名称匹配

通过 name 属性设置标签的名称时,v-model 的值为绑定当前选中的标签名称。

html
<vd-tabbar v-model="active">
  <vd-tabbar-item name="1" title="首页" icon="home" />
  <vd-tabbar-item name="2" title="消息" icon="msg" />
  <vd-tabbar-item name="3" title="购物车" icon="cart" />
  <vd-tabbar-item name="4" title="我的" icon="user" />
</vd-tabbar>
ts
const active = ref('1');

徽标展示

通过 badge 属性设置标签的徽标,通过 dot 设置小圆点展示。

html
<vd-tabbar v-model="active">
  <vd-tabbar-item title="首页" icon="home" />
  <vd-tabbar-item title="消息" icon="msg" badge="9" />
  <vd-tabbar-item title="购物车" icon="cart" dot />
  <vd-tabbar-item title="我的" icon="user" />
</vd-tabbar>
ts
const active = ref(0);

使用插槽

通过插槽可设置自定义内容。

html
<vd-tabbar custom-class="tabbar-action">
  <vd-button type="danger" block :action="handleAction">删除</vd-button>
  <vd-button type="primary" block :action="handleAction">修改</vd-button>
</vd-tabbar>
ts
async function handleAction() {
  await timeout(1000);
}
scss
.tabbar-action .vd-tabbar__content {
  padding: 8px 16px;

  .vd-button {
    font-size: 16px;

    & + .vd-button {
      margin-left: 12px;
    }
  }
}

API

Tabbar Props

参数说明类型默认值
v-model选中标签stringg | number-
fixed是否固定在底部booleantrue
placeholder固定在底部时,是否启用占位元素booleantrue
safe-area-inset-bottom固定在底部时,是否设置底部安全距离booleantrue
z-index在底部时的层级string | number9

TabbarItem Props

参数说明类型默认值
name标签名称stringg | number-
icon图标IconsName-
badge右上角徽标的内容string | number-
dot是否展示右上角小红点booleanfalse

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Tabbar Events

事件名说明回调参数
click点击时触发MouseEvent
change激活标签改变时触发string | number
resize尺寸改变时触发NodeRect

TabbarItem Events

事件名说明回调参数
click点击时触发MouseEvent

Tabbar Slots

名称说明
default自定义内容

TabbarItem Slots

名称说明
default文字内容
icon图标

赣ICP备2025061025号-1