You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To resolve the issue where an extra digit is added to the inputNumber component after the input loses focus when a limit on the number of digits is set, you need to ensure that the value is properly formatted according to the specified precision when the input loses focus. This can be done by modifying the blur method to format the value correctly.
Here is the relevant part of the code with the necessary changes:
methods: {
// ... other methods
blur () {
this.focused = false;
this.$emit('on-blur');
if (!findComponentUpward(this, ['DatePicker', 'TimePicker', 'Cascader', 'Search'])) {
this.handleFormItemChange('blur', this.currentValue);
}
// Ensure the value is formatted according to the precision
if (this.precision !== undefined && this.currentValue !== null) {
this.currentValue = Number(this.currentValue).toFixed(this.precision);
this.$emit('update:modelValue', this.currentValue);
}
},
// ... other methods
}
Additionally, ensure that the precision property is correctly set in the InputNumber component. According to the types/input-number.d.ts file from ViewUIPlus, the precision property is used to define the number of decimal places:
exportdeclareconstInputNumber: DefineComponent<{// ... other properties/** * 数值精度 */precision?: number;// ... other properties}>
This change ensures that when the input loses focus, the value is formatted to the specified precision, preventing any extra digits from being added [1][2].
Activity
dosubot commentedon Jun 27, 2024
To resolve the issue where an extra digit is added to the
inputNumber
component after the input loses focus when a limit on the number of digits is set, you need to ensure that the value is properly formatted according to the specified precision when the input loses focus. This can be done by modifying theblur
method to format the value correctly.Here is the relevant part of the code with the necessary changes:
Additionally, ensure that the
precision
property is correctly set in theInputNumber
component. According to thetypes/input-number.d.ts
file from ViewUIPlus, theprecision
property is used to define the number of decimal places:This change ensures that when the input loses focus, the value is formatted to the specified precision, preventing any extra digits from being added [1][2].
To continue talking to Dosu, mention @dosu.