KMobileTabBar 底部导航
移动端底部图标导航栏:每项一个图标加文案,激活项使用 Element Plus 主色。
基础用法
组件自身使用 position: absolute; bottom: 0,父容器需要有明确高度和定位上下文。
当前页签:home
组件使用 absolute 定位,需要父容器提供定位上下文
docs/examples/mobile-tab-bar/basic.vue
vue
<script setup lang="ts">
import { ref } from 'vue';
import { ChatDotRound, HomeFilled, User } from '@element-plus/icons-vue';
import { KMobileTabBar } from '@wujies/components';
const active = ref('home');
const tabs = [
{ key: 'home', label: '首页', icon: HomeFilled },
{ key: 'msg', label: '消息', icon: ChatDotRound },
{ key: 'me', label: '我的', icon: User }
];
</script>
<template>
<div>
<div style="position: relative; height: 180px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; overflow: hidden">
<div style="padding: 20px; text-align: center; color: var(--el-text-color-regular)">
当前页签:<strong>{{ active }}</strong>
<p style="font-size: 13px; color: var(--el-text-color-secondary)">组件使用 absolute 定位,需要父容器提供定位上下文</p>
</div>
<KMobileTabBar v-model="active" :tabs="tabs" />
</div>
</div>
</template>
API
Attributes
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| modelValue | 当前页签 key,支持 v-model | string | 必填 |
| tabs | 导航项 { key, label, icon } | KMobileTab[] | 必填 |
Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| update:modelValue | 导航项切换 | 新的 key |