var num = 123456789; 1.格式化为千分位输出 num.toLocaleString() //"123,456,789" 2.格式化为千分位带$符号输出 num.toLocaleString("en-US",{style:"currency",currency:"USD"}) //"$123,456,789.00" 3.格式化为带¥符号输出 num.toLocaleString("zh-Hans-CN",{style:"currency",currency:"CNY"}) //"¥123,456,789.00"
原文地址:https://www.cnblogs.com/zgdawdl/p/11447422.html
时间: 2024-11-13 06:47:18