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