From a44eddf956e7042b64428044f057c76ddf2ac791 Mon Sep 17 00:00:00 2001 From: ‘chensiAb’ <‘chenchenco03@163.com’> Date: Tue, 15 Apr 2025 13:39:20 +0800 Subject: [PATCH] style:自定义导航-返回键样式 --- layout/navCustomBar/CNavCustomBar.vue | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) diff --git a/layout/navCustomBar/CNavCustomBar.vue b/layout/navCustomBar/CNavCustomBar.vue index cad1c7b..38acbd9 100644 --- a/layout/navCustomBar/CNavCustomBar.vue +++ b/layout/navCustomBar/CNavCustomBar.vue @@ -6,7 +6,7 @@ <template> <view class="c-nav-custom-bar" - :style="{height:navBarHeight + 'px',paddingTop:statusBarHeight + 'px',boxSizing:'border-box'}" + :style="{height:navBarHeight + 'px',paddingTop:statusBarHeight + 'px',boxSizing:'border-box',zIndex:99}" > <view class="c-nav-icon" @@ -21,7 +21,7 @@ <view v-if="isNeedBackIcon" class="c-nav-back-icon" - @tap="evt => onBack()" + @tap="evt => handleBack()" > <AtIcon value='chevron-left' @@ -30,7 +30,7 @@ ></AtIcon> </view> </view> - <view class="c-nav-title"> + <view :class="[isNeedBackIcon ? 'c-nav-title-back' : 'c-nav-title']"> {{ title }} </view> </view> @@ -54,6 +54,10 @@ title: { type: String, default: '', + }, + onBack: { + type: Function, + default: () => {}, }, }, computed: {}, @@ -85,15 +89,21 @@ this.statusBarHeight = statusBarHeight; }, - onBack() { - Taro.navigateBack({ - delta: 1, - }); + handleBack() { + this.onBack(); + // Taro.navigateBack({ + // delta: 1, + // }); }, $getStatusBarHeight() { return this.statusBarHeight; }, + + // 使用自定义导航时,需要在主页显示的设置padding的值,此值是导航栏的高度,本导航已经使用固定定位为头部 + $getNavBarHeight() { + return this.navBarHeight; + }, }, }; </script> -- Gitblit v1.9.1