Skip to content

Commit

Permalink
fix: 🐛 修改自动宽度逻辑宽度取值的方式 (#4713)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cat1007 authored Nov 5, 2024
1 parent 62e4718 commit 93c7f08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/input/useInputWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
};

Expand Down

0 comments on commit 93c7f08

Please sign in to comment.