From 14594dadc6ba15bcd5a6cb6601f3537e6d178559 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Mon, 13 Oct 2025 20:44:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(tabbar):=20=E4=BF=AE=E5=A4=8D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E5=B9=B3=E5=8F=B0=E5=8E=9F=E7=94=9Ftabbar?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在支付宝平台添加onMounted钩子处理原生tabbar隐藏,与微信平台逻辑保持一致 --- src/tabbar/index.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tabbar/index.vue b/src/tabbar/index.vue index c600530..9bd3c6d 100644 --- a/src/tabbar/index.vue +++ b/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) {