js 保留两位小数
作者:互联网
1.四舍五入
let value = '3.148'
let realVal = parseFloat(value).toFixed(2)
2.不四舍五入
let value = '3.148'
let tempVal = parseFloat(value).toFixed(3)
let realVal = tempVal.substring(0, tempVal.length - 1)
标签:四舍五入,两位,3.148,realVal,value,js,let,tempVal,小数 来源: https://blog.csdn.net/l1830473688/article/details/114829947