zjk
2026-04-09 06b96c68b0b0811eb310ee23cba7a332d3737e75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<script lang="ts" setup>
const router = useRouter()
 
const route = useRoute()
 
const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } = useTabbar()
 
function handleTabbarChange({ value }: { value: string }) {
  setTabbarItemActive(value)
  router.pushTab({ name: value })
}
 
onMounted(() => {
  // #ifdef APP
  uni.hideTabBar()
  // #endif
  nextTick(() => {
    if (route.name && route.name !== activeTabbar.value.name) {
      setTabbarItemActive(route.name)
    }
  })
})
</script>
 
<script lang="ts">
export default {
  options: {
    addGlobalClass: true,
    virtualHost: true,
    styleIsolation: 'shared',
  },
}
</script>
 
<template>
  <slot />
  <wd-gap safe-area-bottom height="var(--wot-tabbar-height, 50px)" />
  <wd-tabbar
    :model-value="activeTabbar.name" active-color="#0068FF" inactive-color="#1A1A1A" bordered safe-area-inset-bottom fixed custom-class="custom-tabbar-bg"
    @change="handleTabbarChange"
  >
    <wd-tabbar-item
      v-for="(item, index) in tabbarList" :key="index" :name="item.name"
      :value="getTabbarItemValue(item.name)" :title="item.title"
    >
      <template #icon="{ active }">
        <image class="h-[44rpx] w-[44rpx]" :src="active ? item.activeIcon : item.inactiveIcon" mode="aspectFit" />
      </template>
    </wd-tabbar-item>
  </wd-tabbar>
</template>
 
<style lang="scss">
.custom-tabbar-bg {
  border-radius: 20rpx 20rpx 0 0;
  overflow: hidden;
  border-top: 2rpx solid var(--wot-color-border-light);
}
</style>