Put the amount number in the formatted form?

1. The amount number is sent from the backend

price:"1111.00"  //

2, realization effect

3, my own implementation ideas

make the number + into an array and add items with insufficient tables (empty characters), and cycle through the page

implementation is a bit low, is there a good implementation scheme

4, address demonstration

http://jsrun.net/YbXKp/edit

Jul.05,2022

string blanks can be filled using the padStart method of String .

  

there is still bug. It would be wrong if the data is changed to 1111.0 to show the amount. I think it is still divided into decimal and integer parts, with two decimal places in length, which is not enough to complement 0

.
Menu