src/utils/index.js
class Utils {
// f代表需要计算的表达式,digit代表小数位数
static toFixedNumber (f, digit = 2) {
// Math.pow(指数,幂指数)
const m = Math.pow(10, digit)
// Math.round() 四舍五入
return Math.round(f * m, 10) / m
}
}
export default Utils
使用
{{ $Utils.toFixedNumber(value) }}
网友评论