From 7b21f94fef89458f832ac3f0412fd7f4affc7ac8 Mon Sep 17 00:00:00 2001 From: Cat1007 <54425790+Cat1007@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:30:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=BD=E5=BA=A6=E4=B8=8B=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E7=B2=BE=E5=BA=A6=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#4754)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/input/useInputWidth.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/input/useInputWidth.ts b/src/input/useInputWidth.ts index 8f4d2abaed..0c3ac250bb 100644 --- a/src/input/useInputWidth.ts +++ b/src/input/useInputWidth.ts @@ -15,9 +15,8 @@ export default function useInputWidth( const updateInputWidth = () => { if (!inputPreRef.value || !inputRef.value) return; - // 使用 offsetWidth,会丢失精度,但是在配合 transform 的场景下,不会受到 scale 影响从而设置到错误的宽度 - const width = inputPreRef.value.offsetWidth; - inputRef.value.style.width = `${width || 0}px`; + // 使用 getComputedStyle 规避 transform 带来的影响 + inputRef.value.style.width = getComputedStyle(inputPreRef.value).width; }; useResizeObserver(inputPreRef, () => {