取input 组件值得时候, 整形一切正常, 但是有小数时候结果就会错误,, 解决如下:
1 //使用new Number 会自动取对应类型的值 2 var number1= new Number(document.getElementById('input1').value) 3 var number2 = new Number(document.getElementById('input2').value) 4 5 var sun = number1 + number2 ; 6 //用 Number.toFixed(x) x 是精确的位数, Number是你的原数据 7 document.getElementById('inputSun').setValue(sun.toFixed(2) );