用js实现千位分隔符?
function commafy(num) { return num && num .toString() .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) { return $1 + ","; }); } console.log(commafy(1234567.90)); //1,234,567.90
function commafy(num) { return num && num .toString() .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) { return $1 + ","; }); } console.log(commafy(1234567.90)); //1,234,567.90