function toDecimal(x) {
var f = parseFloat(x);
if (isNaN(f)) {
return false;
}
var f = Math.round(x * 100) / 100;
var s = f.toString();
var rs = s.indexOf(".");
if (rs < 0) {
rs = s.length;
s += ".";
}
while (s.length <= rs + 2) {
s += "0";
}
// return s;
console.log(s)
}
当多个input调用时赋不了值:
AA() {
this.age = this.toDecimal(this.age, 4);
},
BB() {
this.height = this.toDecimal(this.height, 2);
}
input调用对应AA、BB方法;