mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 11:17:46 +08:00
fix(components): [input-number] Fix value decimals miss prop precision (#8587)
* fix(components): [input-number] Fix value decimals miss prop precision
This commit is contained in:
parent
4fe9c2bd6c
commit
d20e58ecbb
@ -94,6 +94,22 @@ describe('InputNumber.vue', () => {
|
||||
expect(wrapper.find('input').element.value).toEqual('4')
|
||||
})
|
||||
|
||||
test('value decimals miss prop precision', async () => {
|
||||
const num = ref(0.2)
|
||||
const wrapper = mount(() => (
|
||||
<InputNumber step-strictly={true} step={0.1} v-model={num.value} />
|
||||
))
|
||||
const elInputNumber = wrapper.findComponent({ name: 'ElInputNumber' }).vm
|
||||
elInputNumber.increase()
|
||||
await nextTick()
|
||||
expect(wrapper.find('input').element.value).toEqual('0.3')
|
||||
num.value = 0.4
|
||||
await nextTick()
|
||||
elInputNumber.decrease()
|
||||
await nextTick()
|
||||
expect(wrapper.find('input').element.value).toEqual('0.3')
|
||||
})
|
||||
|
||||
describe('precision accuracy 2', () => {
|
||||
const num = ref(0)
|
||||
const wrapper = mount(() => (
|
||||
|
@ -201,7 +201,7 @@ const verifyValue = (
|
||||
newVal = isString(valueOnClear) ? { min, max }[valueOnClear] : valueOnClear
|
||||
}
|
||||
if (stepStrictly) {
|
||||
newVal = Math.round(newVal / step) * step
|
||||
newVal = toPrecision(Math.round(newVal / step) * step, precision)
|
||||
}
|
||||
if (!isUndefined(precision)) {
|
||||
newVal = toPrecision(newVal, precision)
|
||||
|
Loading…
Reference in New Issue
Block a user