Sfoglia il codice sorgente

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

Utopia 8 mesi fa
parent
commit
2f95bc2f5f
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 4 4
      src/tabbar/index.vue

+ 4 - 4
src/tabbar/index.vue

@@ -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>