diff --git a/packages/uni-app-plus/dist/uni-app-view.umd.js b/packages/uni-app-plus/dist/uni-app-view.umd.js index 11102893855e8ede5c0a9e3409fc3ff165408137..fa23fcfbcd9d29778a5680301fd81a1d48a19f73 100644 --- a/packages/uni-app-plus/dist/uni-app-view.umd.js +++ b/packages/uni-app-plus/dist/uni-app-view.umd.js @@ -14515,16 +14515,17 @@ function updatePosition() { const el = rootRef.value; const rect = el.getBoundingClientRect(); + const keys = ["width", "height"]; hidden.value = rect.width === 0 || rect.height === 0; if (!hidden.value) { position.position = getFixed(el) ? "absolute" : "static"; - const keys = ["top", "left", "width", "height"]; - keys.forEach((key) => { - let val = rect[key]; - val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val; - position[key] = val + "px"; - }); + keys.push("top", "left"); } + keys.forEach((key) => { + let val = rect[key]; + val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val; + position[key] = val + "px"; + }); } let request = null; function requestPositionUpdate() { diff --git a/packages/uni-app-plus/src/helpers/useNative.ts b/packages/uni-app-plus/src/helpers/useNative.ts index 77b989debadc749318196a8400a996e802523a12..ca6a4771c622fc5ede57341d78a94669c6b1045d 100644 --- a/packages/uni-app-plus/src/helpers/useNative.ts +++ b/packages/uni-app-plus/src/helpers/useNative.ts @@ -51,24 +51,25 @@ export function useNative(rootRef: Ref) { function updatePosition() { const el = rootRef.value as HTMLElement const rect = el.getBoundingClientRect() + const keys: Prop[] = ['width', 'height'] hidden.value = rect.width === 0 || rect.height === 0 if (!hidden.value) { position.position = getFixed(el) ? 'absolute' : 'static' - const keys: Prop[] = ['top', 'left', 'width', 'height'] - keys.forEach((key) => { - let val = rect[key] - val = - key === 'top' - ? val + - (position.position === 'static' - ? document.documentElement.scrollTop || - document.body.scrollTop || - 0 - : getNavigationBarHeight()) - : val - position[key] = val + 'px' - }) + keys.push('top', 'left') } + keys.forEach((key) => { + let val = rect[key] + val = + key === 'top' + ? val + + (position.position === 'static' + ? document.documentElement.scrollTop || + document.body.scrollTop || + 0 + : getNavigationBarHeight()) + : val + position[key] = val + 'px' + }) } let request: null | number = null