Methods
(inner) formatNumber(number, precisionopt, thousandopt) → {String}
格式化数值为特定格式
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
number | Number | 需要格式化的数值 | ||
precision | Number | <optional> | 2 | 保留小数点 |
thousand | String | <optional> | ',' | 千分位分隔符 |
- Source
Returns:
- Type:
- String
Example
formatNumber(1000.22,1,',')
// '1,000.2'
(inner) getPercent(value, totalopt) → {String}
获取百分比
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value | Number | 数值 | ||
total | Number | <optional> | 100 | 总数值 |
- Source
Returns:
百分比
- Type:
- String
Example
getPercent(0)
// 0%
(inner) toFixed(num, sopt) → {String}
重新避免原函数精度不准的问题
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
num | Number | 数值 | ||
s | Number | <optional> | 2 | 保留小数点位数 默认为2 |
- Source
Returns:
- Type:
- String
Example
toFixed(25.244)
// 25.24