Skip to content

Commit 344b1ac

Browse files
authored
fix: 🐛确保inputNumber输入值在设定的最小值和最大值之间 (#610)
closes:#602
1 parent ce64daf commit 344b1ac

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/uni_modules/wot-design-uni/components/wd-input-number/wd-input-number.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ watch(
7777
function updateBoundary() {
7878
debounce(() => {
7979
const value = formatValue(inputValue.value)
80+
console.log(value, 'value')
8081
if (!isEqual(inputValue.value, value)) {
8182
setValue(value)
8283
}
@@ -200,6 +201,12 @@ function formatValue(value: string | number) {
200201
if (props.precision !== undefined) {
201202
value = value.toFixed(props.precision)
202203
}
204+
if (value > props.max) {
205+
value = props.max
206+
}
207+
if (value < props.min) {
208+
value = props.min
209+
}
203210
204211
return Number(value)
205212
}

0 commit comments

Comments
 (0)