商户ID只能输入数字
bug原因:前提是输入框先输入汉字,再输入英文,在输入数字,点击清除就清除不了
以下加onkeyup,或者oninput等都不行
<el-form-item label="商户ID:" prop="userId">
<el-input v-model="search.userId" placeholder="请输入商户ID" onkeyup="this.value=this.value.replace(/[^\d]/g,'')"
@click="confirmTelephone" maxlength="20" size="small"/>
</el-form-item>
confirmTelephone(){
let _this=this
if (!/^1[0-9]{10}$/.test(_this.search.userId))
_this.search.userId = '';
},
解决方法:
<template slot="search">
<el-form-item label="商户ID:" prop="userId">
<el-input v-model="search.userId" placeholder="请输入商户ID" @input="inputChange" maxlength="20" size="small"/>
</el-form-item>
inputChange(val) {
this.search.userId = this.search.userId.replace(/[^0-9.]/g, '')
},