/**
* js保留两位小数(不四舍五入)
* @description formatDecimal
*/exportfunctionformatDecimal(num, decimal){
num = num.toString()let index = num.indexOf('.')if(index !==-1){
num = num.substring(0, decimal + index +1)}else{
num = num.substring(0)}returnparseFloat(num).toFixed(decimal)}
/**
* 四舍五入保留2位小数(若第二位小数为0,则保留一位小数)
* @description keepTwoDecimal
*/exportfunctionkeepTwoDecimal(num){var result =parseFloat(num);if(isNaN(result)){alert('传递参数错误,请检查!');returnfalse;}
result = Math.round(num *100)/100;return result;}