格式化数值,千分号
formatInt(v){ // 1234567890 => "1,234,567,890" return (v+"").replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }, formatFloat(v){ // 1234567890.1234 => "1,234,567,890.1234" return (v+"").replace(/(\d)(?=(\d{3})+\.)/g, '$1,') }, formatFloatEx(v,length){ // length=2 1234567890.1234 => "1,234,567,890.12" return v.toFixed(length).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') }, formatJPercent(v){ // 0.66888 => 66.89% return (v*100).toFixed(2)+'%'; }
GarsonZhang www.yesdotnet.com
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post YES开发框架