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
var formattedValue = value
// Remove whitespace on either side
.trim()
// Shorten to 2 decimal places
.slice(0, value.indexOf('.') + 3)
The reason is that the input will trigger an input event to trigger this validation function. When the input does not contain ".", The value.indexOf('.') always returns -1, so the .slice(0, value.indexOf('.') + 3) always returns the total .slice (0,2), thus limiting the input.
It is recommended to add a judgment as follows:
var formattedValue = value
// Remove whitespace on either side
.trim()
// To determine whether it is included "." and shorten to 2 decimal places
.slice(0, value.indexOf('.')==-1?(value.length):(value.indexOf('.')+3))
The text was updated successfully, but these errors were encountered:
https://vuejs.org/v2/guide/components.html#Form-Input-Components-using-Custom-Events
the first example about "a component to work with v-model" contain a validator function,howerver,you can not enter a number greater than 2 digits, such as 123.45, the code is as follows:
The reason is that the input will trigger an input event to trigger this validation function. When the input does not contain ".", The value.indexOf('.') always returns -1, so the .slice(0, value.indexOf('.') + 3) always returns the total .slice (0,2), thus limiting the input.
It is recommended to add a judgment as follows:
The text was updated successfully, but these errors were encountered: