zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    js & float number bug

    前端最好不要处理任何的 float number 的计算/精确度转换的操作,不热很容易丢失精度,显示错误!

    前端显示个 0.0 都很费劲,最好的方式就是数值型的数据后端全部给字符串

    
    
    labelWeight = 0;
    if(labelWeight === 0) {
        labelWeight = labelWeight + `.0`;
    } else {
        if (!labelWeight) {
            labelWeight = "";
        }
    }
    "0.0"
    labelWeight = null;
    if(labelWeight === 0) {
        labelWeight = labelWeight + `.0`;
    } else {
        if (!labelWeight) {
            labelWeight = "";
        }
    }
    ""
    labelWeight = "";
    if(labelWeight === 0) {
        labelWeight = labelWeight + `.0`;
    } else {
        if (!labelWeight) {
            labelWeight = "";
        }
    }
    ""
    labelWeight = "0.0";
    if(labelWeight === 0) {
        labelWeight = labelWeight + `.0`;
    } else {
        if (!labelWeight) {
            labelWeight = "";
        }
    }
    undefined
    labelWeight = "0.999";
    if(labelWeight === 0) {
        labelWeight = labelWeight + `.0`;
    } else {
        if (!labelWeight) {
            labelWeight = "";
        }
    }
    undefined
    labelWeight;
    "0.999"
    
    

    solution

    后端返回处理后的 String 数据

  • 相关阅读:
    sap function 常用的一些系统函数
    sap ok code
    提高PHP代码质量36计
    sap links /sap 学习资源链接
    sap tips/ sap 小技巧
    php写导入,导出 mysql csv
    SAP Tables 表
    [C#] 处理 Json
    [Rootkit] 无痕 hook 硬件断点
    [Rootkit] dll 隐藏 VAD
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/10510489.html
Copyright © 2011-2022 走看看