input输入框输入纯数字、数字及小数点
1.纯数字
<div> <el-form-item label="开户行:" prop="bankName" > <el-input v-model="formData.bankName" maxlength="100" @keyup.native="proving"/> </el-form-item> </div>
methods方法
proving() { this.formData.bankName = this.formData.bankName.replace(/[^\.\d]/g,''); this.formData.bankName = this.formData.bankName.replace('.',''); },
2.数字及两位小数点
<el-input
v-model="form.personIncome"
onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
placeholder="单位:元">
</el-input>