Portrait.uvue
1.39 KB
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
<template>
<view class="home-tabbar home-tabbar-portrait home-tabbar-portrait-pad">
<un-tabbar :model-value="currentTabIndex"
class="portrait-un-tabbar"
:fixed="true"
:placeholder="false"
:safe-area-inset-bottom="true"
active-color="#3773f8"
inactive-color="#8a98b5"
bg-color="#ffffff"
@change="emit('tabChange', ($event as string | number))">
<un-tabbar-item v-for="(item, index) in tabs"
:key="index"
:name="index"
:text="item.label">
<template #icon="{ active }">
<image class="tabbar-icon-img"
mode="aspectFit"
:src="active == true ? item.iconSrcActive : item.iconSrcInactive" />
</template>
</un-tabbar-item>
</un-tabbar>
</view>
</template>
<script setup lang="uts">
import { useTabbarCommon } from "./hooks";
const props = defineProps<{
currentTabIndex: number
}>();
const emit = defineEmits<{
tabChange: [name: string | number]
}>();
const { tabs } = useTabbarCommon();
</script>
<style scoped lang="scss">
@import "../styles/common.scss";
/* 与 layout-root 注入的 index.vars.uts 中 --tabbar-icon-size 一致;横屏侧栏见 TabbarLandscape .landscape-vertical-tabs__icon */
.tabbar-icon-img {
width: var(--tabbar-icon-size, 24px);
height: var(--tabbar-icon-size, 24px);
}
</style>