diff --git a/miniprogram/components3.0/nav-bar/nav-bar.less b/miniprogram/components3.0/nav-bar/nav-bar.less index 4adce12..f10849b 100644 --- a/miniprogram/components3.0/nav-bar/nav-bar.less +++ b/miniprogram/components3.0/nav-bar/nav-bar.less @@ -14,7 +14,6 @@ } .nav-bar__inner { - height: @nav-inner-height; display: flex; flex-direction: row; align-items: center; @@ -71,6 +70,7 @@ font-weight: @fw-nav-title; color: @color-nav-title; letter-spacing: @ls-nav-title; + line-height: 1; flex: 1; min-width: 0; } diff --git a/miniprogram/components3.0/nav-bar/nav-bar.ts b/miniprogram/components3.0/nav-bar/nav-bar.ts index e5736be..c135c27 100644 --- a/miniprogram/components3.0/nav-bar/nav-bar.ts +++ b/miniprogram/components3.0/nav-bar/nav-bar.ts @@ -1,4 +1,4 @@ -import { NAV_INNER_PX } from '../../utils/navMetrics'; +import { getNavInnerPx } from '../../utils/navMetrics'; const HOME_TAB_URL = '/pages/home/home'; const HOME_ROUTE = 'pages/home/home'; @@ -19,6 +19,7 @@ Component({ }, data: { statusBarHeight: 0, + navInnerHeight: 44, navBlockHeight: 0, leftActionType: 'none' as 'none' | 'back' | 'home' | 'brand', /** 仅首页(Tab 根页)在 logo 旁展示「涂鸦丫」;其余主 Tab 只展示 logo */ @@ -27,9 +28,11 @@ Component({ lifetimes: { attached() { const { statusBarHeight } = wx.getWindowInfo(); + const navInnerHeight = getNavInnerPx(); this.setData({ statusBarHeight, - navBlockHeight: statusBarHeight + NAV_INNER_PX, + navInnerHeight, + navBlockHeight: statusBarHeight + navInnerHeight, }); this.syncLeftAction(); }, diff --git a/miniprogram/components3.0/nav-bar/nav-bar.wxml b/miniprogram/components3.0/nav-bar/nav-bar.wxml index f33fe86..cd296b2 100644 --- a/miniprogram/components3.0/nav-bar/nav-bar.wxml +++ b/miniprogram/components3.0/nav-bar/nav-bar.wxml @@ -1,7 +1,7 @@ - + 0 && Number.isFinite(inner)) { + return Math.round(inner); + } + } catch (e) { + // ignore, fallback below + } + return 44; +} + +export function getNavInnerPx(): number { + if (cachedInnerPx === null) { + cachedInnerPx = computeInnerPx(); + } + return cachedInnerPx; +} + +/** 兼容旧调用:保留常量导出,启动时取一次胶囊几何。 */ +export const NAV_INNER_PX = getNavInnerPx();