1.0.11 • Published 1 month ago

@tanzhenxing/zx-tabbar v1.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

zx-tabbar 底部导航栏

此组件提供了自定义 tabbar 的能力,支持 H5、小程序、App,适合多端项目使用。

组件特性

  • 支持自定义图标、文本、徽标、圆点
  • 支持固定底部、占位防塌陷
  • 支持安全区适配
  • 支持拦截切换、事件回调
  • 兼容多端(H5/小程序/App)

基本用法

<template>
  <zx-tabbar :value="tab" @change="tab = $event" :items="tabbarList" />
</template>
<script setup>
import { ref } from 'vue';
const tab = ref(0);
const tabbarList = [
  { icon: 'home', title: '首页' },
  { icon: 'photo', title: '放映厅' },
  { icon: 'play-right', title: '直播' },
  { icon: 'account', title: '我的' }
];
</script>

属性说明

属性名说明类型默认值
value当前选中项的索引或 nameString/Number0
itemstabbar 配置项数组Array[]
safeAreaInsetBottom是否为 iPhoneX 留出安全距离Booleantrue
border是否显示上方边框Booleantrue
zIndex层级 z-indexString/Number100
activeColor选中标签颜色String#ff0000
inactiveColor未选中标签颜色String#7d7e80
fixed是否固定在底部Booleantrue
placeholder固定时是否占位防塌陷Booleantrue
heighttabbar 高度String100rpx
customStyle外部自定义样式Object{}

items 配置项说明

属性名说明类型
icon图标名/图片String
title文本String
badge角标数字String/Number
dot是否显示圆点Boolean
name唯一标识(可选)String/Number

事件说明

事件名说明回调参数
change切换选项时触发index/name

常见用法

显示徽标/圆点

<zx-tabbar :value="tab" @change="tab = $event" :items="[
  { icon: 'home', title: '首页', dot: true },
  { icon: 'photo', title: '放映厅', badge: 3 },
  { icon: 'play-right', title: '直播' },
  { icon: 'account', title: '我的' }
]" />

拦截切换

<zx-tabbar :value="tab" @change="onTabChange" :items="tabbarList" />
<script setup>
function onTabChange(index) {
  if (index === 1) {
    uni.showToast({ title: '请先登录', icon: 'none' });
    return;
  }
  tab.value = index;
}
</script>

固定底部

<zx-tabbar :value="tab" @change="tab = $event" :items="tabbarList" fixed placeholder safeAreaInsetBottom />

插槽

注意事项

  • 请确保 items 数组不为空
  • 支持多端,无需关心平台差异

参考文档

1.0.9

1 month ago

1.0.8

2 months ago

1.0.11

1 month ago

1.0.10

1 month ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago