mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [input-number] dynamic precision render value (#21558)
* fix(components): [input-number] dynamic precision render value * chore: test case
This commit is contained in:
@@ -36,6 +36,25 @@ describe('InputNumber.vue', () => {
|
||||
expect(wrapper.find('p').element.innerText).toBeUndefined()
|
||||
})
|
||||
|
||||
test('dynamic change the precision value should correct re-render', async () => {
|
||||
const num = ref(123.12)
|
||||
const precision = ref(1)
|
||||
const wrapper = mount(() => (
|
||||
<>
|
||||
<InputNumber
|
||||
modelValue={num.value}
|
||||
placeholder="input number"
|
||||
precision={precision.value}
|
||||
/>
|
||||
</>
|
||||
))
|
||||
await nextTick()
|
||||
expect(wrapper.find('input').element.value).toEqual('123.1')
|
||||
precision.value = 2
|
||||
await nextTick()
|
||||
expect(wrapper.find('input').element.value).toEqual('123.12')
|
||||
})
|
||||
|
||||
test('set modelValue undefined to display placeholder', async () => {
|
||||
const inputText = ref<number | undefined>(1)
|
||||
const wrapper = mount(() => (
|
||||
|
||||
@@ -358,6 +358,13 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.precision,
|
||||
() => {
|
||||
data.currentValue = verifyValue(props.modelValue)
|
||||
}
|
||||
)
|
||||
onMounted(() => {
|
||||
const { min, max, modelValue } = props
|
||||
const innerInput = input.value?.input as HTMLInputElement
|
||||
|
||||
Reference in New Issue
Block a user