关于百分数转换的问题
发布于 5 年前 作者 guiying10 4956 次浏览 来自 问答

从后台取到的小数转化为百分数(例如0.29转换成29%),某些小数进行乘法计算时,数据变为了浮点型,截图如下:

1 回复

可参考 number 原型的一些有用函数

   /** Copyright (c) Microsoft Corporation. All rights reserved.

      * 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.
      */

    toPrecision(precision?: number): string;


回到顶部