我目前正在尝试处理英语(en)和德语(de)语言的数字。我有一个全局函数,它可以做到这一点,并且在数字达到1000或更多之前工作得很好。
function getLocaleString(floatValue) {
var CurrentCulture = $('#CurrentCulture').val();
if (CurrentCulture != "" && CurrentCulture != null) {
return floatValue.toLocaleString(CurrentCulture, { minimumFractionDigits: 2,
maximumFractionDigits: 2 });
}
return floatValue;
}有没有办法去掉逗号,这样数字就不会失真?
发布于 2020-02-13 23:54:03
您可以只使用replace()。Javascript的字符串替换方法
floatValue.toLocaleString(CurrentCulture, {minimumFractionDigits: 2,
maximumFractionDigits: 2 }).replace(/,/g, "");;g修饰符用于全局替换,以替换指定值的所有匹配项。
https://stackoverflow.com/questions/60211568
复制相似问题