//数字转成千分位代码
function numberconvert(str){
var num = parseFloat(str).toFixed(3);
var s = num.substring(0, (num.length-1));//取小数位2位
return s && s.toString().replace(/(\d)(?=(\d{3})+.)/g, function(1) {
return $1 + ",";
});
}
//数字转成千分位代码
function numberconvert(str){
var num = parseFloat(str).toFixed(3);
var s = num.substring(0, (num.length-1));//取小数位2位
return s && s.toString().replace(/(\d)(?=(\d{3})+.)/g, function(1) {
return $1 + ",";
});
}
本文标题:数字转成千分位代码(js正则实现)
本文链接:https://www.haomeiwen.com/subject/aswrlqtx.html
网友评论