一.四舍五入
我们可以使用 toFixed对数值进行处理
运算结果:
二.不四舍五入的情况
1.先把小数变整数
Math.floor(18.6684514000 * 100) / 100
// 输出结果为 18.66
三.在vue中如何使用
1.
centerTwoYewei.value = Number(res.data.data[0].pointValue).toFixed(2)
直接在所要进行四舍五入的数据后面加上toFixed(number)
number就是你要四舍五入的位数
为了保持规范,需要在前面加上一个Number将数据包裹起来