关于百分数转换的问题
从后台取到的小数转化为百分数(例如0.29转换成29%),某些小数进行乘法计算时,数据变为了浮点型,截图如下:
1 回复
可参考 number 原型的一些有用函数
* Returns a string representing a number in fixed-point notation. * [@param](/user/param) fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ toFixed(fractionDigits?: number): string; /** * Returns a string containing a number represented in exponential notation. * [@param](/user/param) fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ toExponential(fractionDigits?: number): string; /** * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. * [@param](/user/param) precision Number of significant digits. Must be in the range 1 - 21, inclusive. */
|