Explorar el Código

fix(tabbar): 修复支付宝平台原生tabbar隐藏问题

在支付宝平台添加onMounted钩子处理原生tabbar隐藏,与微信平台逻辑保持一致
feige996 hace 6 meses
padre
commit
14594dadc6
Se han modificado 1 ficheros con 16 adiciones y 1 borrados
  1. 16 1
      src/tabbar/index.vue

+ 16 - 1
src/tabbar/index.vue

@@ -39,7 +39,7 @@ function handleClick(index: number) {
     uni.navigateTo({ url })
   }
 }
-// #ifndef MP-WEIXIN
+// #ifndef MP-WEIXIN || MP-ALIPAY
 // 因为有了 custom:true, 微信里面不需要多余的hide操作
 onLoad(() => {
   // 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
@@ -54,6 +54,21 @@ onLoad(() => {
   })
 })
 // #endif
+
+// #ifdef MP-ALIPAY
+onMounted(() => {
+  // 解决支付宝自定义tabbar 未隐藏导致有2个 tabBar 的问题; 注意支付宝很特别,需要在 onMounted 钩子调用
+  needHideNativeTabbar
+  && uni.hideTabBar({
+    fail(err) {
+      console.log('hideTabBar fail: ', err)
+    },
+    success(res) {
+      // console.log('hideTabBar success: ', res)
+    },
+  })
+})
+// #endif
 const activeColor = 'var(--wot-color-theme, #1890ff)'
 const inactiveColor = '#666'
 function getColorByIndex(index: number) {