In vue, input is limited to 2 decimal places at most, and the function is implemented, but there are minor flaws.

there is an input in vue I use v-model and watch to get the input number, and now enter at most 2 decimal places
although the function is realized, but when entering, you can actually enter 3 decimal places, but I intercepted the input data through watch and re-assigned the value to achieve the requirement of up to 2 decimal places, but in the input process, the input data has been flashing. The experience is not very good

excuse me, are there any other solutions for this kind of requirements?

used in vue

Feb.28,2021

implementation can't figure out a solution


you don't have to monitor computing in real time. When you lose focus on an event in input, you can do a Filter of the input data.


bind data to input's max length and count integer + 3 places when there is a decimal point. No practice can try


method 1: you can use binding keyboard event handling, watch, need to change the value of input before your method will be executed, so the input will flash. You can listen to the keydown event again and return directly if two decimal points are met.
method 2: restrict input through the maxlength of input. When entering one place after the decimal point, change the maxlength to the current length + 1


simulate an input box and cursor. Then press the monitor button--

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e71d86-38e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e71d86-38e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?