//如果是5.00之类的,转换后,应该不要小数点后的位数 let num = 5.34; //let num = 5.00; let arr = num .toString().split("."); let len = 0; if (num[1]) { len = Number(num[1]) == 0 ? 0 : num[1].length; } num = len == 0 ? Number(num ).toFixed(0) : Number(num ).toFixed(2);
//如果是5.00之类的,转换后,应该不要小数点后的位数 let num = 5.34; //let num = 5.00; let arr = num .toString().split("."); let len = 0; if (num[1]) { len = Number(num[1]) == 0 ? 0 : num[1].length; } num = len == 0 ? Number(num ).toFixed(0) : Number(num ).toFixed(2);