逗号的当前号码会干扰数字长度?

时间:2018-06-17 02:41:13

标签: javascript

我尝试使用逗号显示一个数字,如(1,000)中所示的简单计算器。计算器,或者不用来自用户的数字重载,将长度限制为22位,但当我使用.toStringLocate()运行其中有多少位数时,它似乎将它视为一位数,即使它更大。有没有办法让这两种功能同时工作?

    var digits = reactant2.toString().length;
if (digits >= 21 && vi > 1) {
    a.style.pointerEvents = "none";
    b.style.pointerEvents = "none";
    c.style.pointerEvents = "none";
    d.style.pointerEvents = "none";
    e.style.pointerEvents = "none";
    f.style.pointerEvents = "none";
    g.style.pointerEvents = "none";
    h.style.pointerEvents = "none";
    i.style.pointerEvents = "none";
    j.style.pointerEvents = "none";
    k.style.pointerEvents = "none";
    }
     if (vi === 0 && reactant != "0"){
    document.getElementById('result').innerHTML = reactant.toLocaleString();
} else if (vi > 1 && reactant2 != "") {
    document.getElementById('result').innerHTML = reactant2.toLocaleString();
 }

0 个答案:

没有答案