Skip to content

Commit

Permalink
fix: 🐛 修复InputNumber步进器组件在初始化时未发生变化仍触发change的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xuqingkai authored and Moonofweisheng committed Apr 23, 2024
1 parent 45980c5 commit 6ac20fd
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -36,7 +36,7 @@ export default {

<script lang="ts" setup>
import { ref, watch } from 'vue'
import { debounce, isDef } from '../common/util'
import { debounce, isDef, isEqual } from '../common/util'
import { inputNumberProps } from './types'
const props = defineProps(inputNumberProps)
Expand Down Expand Up @@ -75,7 +75,9 @@ watch(
function updateBoundary() {
debounce(() => {
const value = formatValue(inputValue.value)
setValue(value)
if (!isEqual(inputValue.value, value)) {
setValue(value)
}
splitDisabled(value)
}, 30)()
}
Expand Down Expand Up @@ -161,13 +163,18 @@ function handleFocus(event: any) {
function handleBlur() {
const value = formatValue(inputValue.value)
setValue(value)
if (!isEqual(inputValue.value, value)) {
setValue(value)
}
emit('blur', {
value
})
}
function dispatchChangeEvent(value: string | number, change: boolean = true) {
if (isEqual(inputValue.value, value)) {
return
}
inputValue.value = value
change && emit('update:modelValue', inputValue.value)
change && emit('change', { value })
Expand Down

0 comments on commit 6ac20fd

Please sign in to comment.