JS小数位数不足二位,自动补零0
作者:互联网
function returnFloat(value){
var value = Math.round(parseFloat(value) * 100) / 100;
var s = value.toString().split(".");
if(s.length== 1){
value = value.toString() + ".00";
return value;
}
if (s.length > 1) {
if (s[1].length < 2) {
value = value.toString() + "0";
}
return value;
}
}
标签:return,value,JS,length,toString,var,小数位,100,补零 来源: https://www.cnblogs.com/tsxx/p/15074599.html