Skip to content

Commit

Permalink
fix(Input): 修复 Input type="number" 时,无法输入小数位末尾 0 的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jianglei committed Oct 16, 2024
1 parent 94557c9 commit ca97bc9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/input/useInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ export default function useInput(props: ExtendsTdInputProps, expose: (exposed: R
setInnerValue(getOutputValue(val, props.type), { e, trigger: 'input' });
// 受控
nextTick(() => {
setInputElValue(innerValue.value);
// type = 'number'时, 解决小数点后面有 0 自动删除的问题
if (props.type === 'number' && /\.(\d+)?0$/.test(val)) {
setInputElValue(val);
} else {
setInputElValue(innerValue.value);
}
});
};

Expand Down

0 comments on commit ca97bc9

Please sign in to comment.