Skip to content

Commit 6ac20fd

Browse files
xuqingkaiMoonofweisheng
authored andcommitted
fix: 🐛 修复InputNumber步进器组件在初始化时未发生变化仍触发change的问题
1 parent 45980c5 commit 6ac20fd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636

3737
<script lang="ts" setup>
3838
import { ref, watch } from 'vue'
39-
import { debounce, isDef } from '../common/util'
39+
import { debounce, isDef, isEqual } from '../common/util'
4040
import { inputNumberProps } from './types'
4141
4242
const props = defineProps(inputNumberProps)
@@ -75,7 +75,9 @@ watch(
7575
function updateBoundary() {
7676
debounce(() => {
7777
const value = formatValue(inputValue.value)
78-
setValue(value)
78+
if (!isEqual(inputValue.value, value)) {
79+
setValue(value)
80+
}
7981
splitDisabled(value)
8082
}, 30)()
8183
}
@@ -161,13 +163,18 @@ function handleFocus(event: any) {
161163
162164
function handleBlur() {
163165
const value = formatValue(inputValue.value)
164-
setValue(value)
166+
if (!isEqual(inputValue.value, value)) {
167+
setValue(value)
168+
}
165169
emit('blur', {
166170
value
167171
})
168172
}
169173
170174
function dispatchChangeEvent(value: string | number, change: boolean = true) {
175+
if (isEqual(inputValue.value, value)) {
176+
return
177+
}
171178
inputValue.value = value
172179
change && emit('update:modelValue', inputValue.value)
173180
change && emit('change', { value })

0 commit comments

Comments
 (0)