Recently, lovely products put forward some requirements , Amount tail needs .00 And it's got to carry thousands of characters .
html: <el-input v-model="form.projectAmount" type="txet" placeholder=" Please input project amount "
@blur="projectAmounts" clearable :maxlength="32"></el-input> js:
toThousandsNoZero(num) { return num ? (
(isNaN(parseFloat(num.toString().replace(/,/g, ""))) ? 1 :
parseFloat(num.toString().replace(/,/g,
"")))).toFixed(2).toString().replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
return $1 + ","; }) : ""; }, projectAmounts(){//this.form.projectAmount amount of money
if(isNaN(parseFloat(this.form.projectAmount))){ this.form.projectAmount= 0.00;
}else{ this.form.projectAmount=this.toThousandsNoZero(this.form.projectAmount);
} },
effect :
Technology