From 8f5c0a4adea5ae1a8021fac185df94bc3702ddf6 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 06 Mar 2025 12:32:01 +0800 Subject: [PATCH] Merge branch 'master' of ssh://dev.zhiheiot.com:29418/mob-components --- layout/navCustomBar/CNavCustomBar.vue | 11 ++++++++--- layout/navCustomBar/cNavCustomBar.scss | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/layout/navCustomBar/CNavCustomBar.vue b/layout/navCustomBar/CNavCustomBar.vue index 3110647..065738c 100644 --- a/layout/navCustomBar/CNavCustomBar.vue +++ b/layout/navCustomBar/CNavCustomBar.vue @@ -40,7 +40,6 @@ import Taro from '@tarojs/taro'; import { AtIcon } from 'taro-ui-vue'; import './cNavCustomBar.scss'; -import { helper } from '@components/plugins/echarts/echarts'; export default { name: 'CNavCustomBar', @@ -72,15 +71,16 @@ //获取胶囊对象 let menuButtonObject = Taro.getMenuButtonBoundingClientRect(); // 获取设备系统对象 - var sysInfo = wx.getSystemInfoSync(); + let sysInfo = wx.getSystemInfoSync(); // 获取状态栏高度 let statusBarHeight = sysInfo.statusBarHeight; // 获取胶囊高度 let menuButtonHeight = menuButtonObject.height; // 获取胶囊距离顶部的高度 let distanceTop = menuButtonObject.top; + //计算nav导航栏的高度 let navBarHeight = - statusBarHeight + menuButtonHeight + (distanceTop - statusBarHeight) * 2; //计算nav导航栏的高度(上图蓝色线段的长度) + statusBarHeight + menuButtonHeight + (distanceTop - statusBarHeight) * 2; this.navBarHeight = navBarHeight; this.statusBarHeight = statusBarHeight; }, @@ -94,6 +94,11 @@ $getStatusBarHeight() { return this.statusBarHeight; }, + + // 使用自定义导航时,需要在主页显示的设置padding的值,此值是导航栏的高度,本导航已经使用固定定位为头部 + $getNavBarHeight() { + return this.navBarHeight; + }, }, }; </script> diff --git a/layout/navCustomBar/cNavCustomBar.scss b/layout/navCustomBar/cNavCustomBar.scss index 85104d1..44b0be6 100644 --- a/layout/navCustomBar/cNavCustomBar.scss +++ b/layout/navCustomBar/cNavCustomBar.scss @@ -9,7 +9,10 @@ width: 100%; display: flex; justify-content: center; - position: relative; + position: fixed; + top: 0; + left: 0; + background-color: #fff; .c-nav-icon { position: absolute; left: 0px; -- Gitblit v1.9.1