From c96b07f337fa2516df2b9a51aaabf8edde17d187 Mon Sep 17 00:00:00 2001 From: "Kyour.cn" Date: Thu, 27 Feb 2025 21:30:16 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=8F=92=E4=BB=B6=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BD=9C=E4=B8=BAuniapp=E9=A6=96=E9=A1=B5=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 8ccd7d2df1bb2e33215c21d82687b4beb913c766) --- uni-app/src/components/top-tabbar/top-tabbar.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/uni-app/src/components/top-tabbar/top-tabbar.vue b/uni-app/src/components/top-tabbar/top-tabbar.vue index 592469708..6d1e75708 100644 --- a/uni-app/src/components/top-tabbar/top-tabbar.vue +++ b/uni-app/src/components/top-tabbar/top-tabbar.vue @@ -89,6 +89,8 @@ const props = defineProps({ } }) +const isBack = ref(props.isBack); + // 控制-定位后是否对导航栏进行填充 const isFill = computed(() => { let bool = true; @@ -113,7 +115,18 @@ const topStatusBarData = computed(() => { const navbarInnerStyle = computed(() => { let style = ''; - if(props.isBack){ + // 获取首页url + let weappOptions: any = uni.getStorageSync('weappOptions') + if (weappOptions && weappOptions.path) { + // 获取当前页面的路径 + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1].route; + if(weappOptions.path.indexOf(currentPage) !== -1) { + isBack.value = false; + } + } + + if(isBack.value){ style += 'padding-left: 30rpx;';//30=>右边留边 44=>箭头宽度 10=>箭头的右maring if(topStatusBarData.value.style == 'style-1') //样式一需要居中需要有右边padding辅助 style += 'padding-right:' + (40+30+10) + 'rpx;'; //30=>左边留边 44=>箭头宽度 10=>箭头的右maring -- Gitee