Methods

(inner) formatNumber(number, precisionopt, thousandopt) → {String}

格式化数值为特定格式

Parameters:
NameTypeAttributesDefaultDescription
numberNumber

需要格式化的数值

precisionNumber<optional>
2

保留小数点

thousandString<optional>
','

千分位分隔符

Returns:
Type: 
String
Example
formatNumber(1000.22,1,',')
// '1,000.2'

(inner) getPercent(value, totalopt) → {String}

获取百分比

Parameters:
NameTypeAttributesDefaultDescription
valueNumber

数值

totalNumber<optional>
100

总数值

Returns:

百分比

Type: 
String
Example
getPercent(0)
// 0%

(inner) toFixed(num, sopt) → {String}

重新避免原函数精度不准的问题

Parameters:
NameTypeAttributesDefaultDescription
numNumber

数值

sNumber<optional>
2

保留小数点位数 默认为2

Returns:
Type: 
String
Example
toFixed(25.244)
// 25.24