fix: 自定义 tabbar 时(图标为 image 类型),选中高亮图片无法显示

This commit is contained in:
Utopia
2025-08-19 17:09:04 +08:00
parent f72d8e9a04
commit 2f95bc2f5f

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
// 'i-carbon-code',
import type { CustomTabBarItem } from './config'
import { customTabbarEnable, needHideNativeTabbar, tabbarCacheEnable } from './config'
import { tabbarList, tabbarStore } from './store'
@@ -56,12 +56,12 @@ function getColorByIndex(index: number) {
return tabbarStore.curIdx === index ? activeColor : inactiveColor
}
function getImageByIndex(index: number, item: { iconActive?: string, icon: string }) {
if (!item.iconActive) {
function getImageByIndex(index: number, item: CustomTabBarItem) {
if (!item.activeIcon) {
console.warn('image 模式下,需要配置 iconActive (高亮时的图片),否则无法切换高亮图片')
return item.icon
}
return tabbarStore.curIdx === index ? item.iconActive : item.icon
return tabbarStore.curIdx === index ? item.activeIcon : item.icon
}
</script>