zoukankan      html  css  js  c++  java
  • 关于js的toFixed()方法

    toFixed由于个版本浏览器的支持情况不同,所以不稳定。有的时候四舍五入会直接取小数点后的数字而没有四舍五入。

    针对方法改写toFixed:

    Number.prototype.toFixed = function (s) {
    return (parseInt(this * Math.pow(10, s) + 0.5) / Math.pow(10, s)).toString();
    }


    将重写的方法放在每个页面都需要使用的样式库等地方就可以直接使用toFixed方法了
  • 相关阅读:
    openresty
    ATS 相关
    pandas
    flask
    ansible
    zipline
    bcolz
    数据分析 --- concat
    Go --- 基础使用
    Go --- 基础介绍
  • 原文地址:https://www.cnblogs.com/dragonh/p/9407902.html
Copyright © 2011-2022 走看看