js 将数字转换成千分符并保留小数点后两位值

transitSeparator: function(number) {
        if (!number) {
            return "0.00";
        }
        if (typeof number == "string" && number.indexOf(",") > 0) {
            return number;
        }

        var stringValue = (number * 1).toLocaleString();
        var value = stringValue.split(".");
        if (value.length == 1) {
            return value[0] + ".00";
        } else {
            return value[0] + "." + value[1].padEnd(2, "0").slice(0, 2);
        }
    },

你可能感兴趣的:(javascript,elementui,前端)