找了一下很快就找到了
function moneyFormat(str) { if (str.length <= 3) { return str; } else { return moneyFormat(str.substr(0, str.length - 3)) + "," + (str.substr(str.length - 3)); } }2020-12-23補
//三位一撇 function three(num) { const parts = num.toString().split('.'); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); return parts.join('.');// '$' + }參考網址
點我前往
點我前往