收藏
回答

关于百分数转换的问题

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

最后一次编辑于  2018-05-17  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏关注问题回答

1 个回答

  • HS
    HS
    2018-05-17

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

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

          * Returns a string representing a number in fixed-point notation.
          * @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 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 precision Number of significant digits. Must be in the range 1 - 21, inclusive.
          */

        toPrecision(precision?: number): string;



    2018-05-17
    赞同
    回复