var n = 0.015.toFixed(2);
console.log(n);
真实结果"0.01",但是想得到"0.02",求解决方法
var n = 0.015.toFixed(2);
console.log(n);
真实结果"0.01",但是想得到"0.02",求解决方法
13 回答12.9k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
6 回答1.1k 阅读
2 回答1.3k 阅读✓ 已解决
toFixed
存在兼容性问题,0.015.toFixed(2)
各浏览器结果:可以这样写:
Math.round(0.015*100)/100
,抽取成公用的方法