<input type="text" v-model="number" @input="onlyNumber(this)" :focus="true" maxlength="10" />
onlyNumber(number){
console.log(this.number)
let t = this.number.charAt(0);
this.number = this.number.replace(/[^\d\.\-]/g,'');
this.number = this.number.replace(/^0\d[0-9]*/g,'');
this.number =this.number.replace(/^\./g,'');
this.number =this.number.replace(/\.{2,}/g,'.');
this.number = this.number.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
this.number = this.number.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
if(t == '-'){ return; }
}
9***@qq.com
- 发布:2021-05-24 15:06
- 更新:2021-05-24 15:06
- 阅读:348
0 个回复