使用type="number"
onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
oninput="if(value.length>11)value=value.slice(0,11)"
会有bug:拼音输入法还是可以输入E e字母;
解决方案:
<el-input v-model="titleForm.phoneNumber" placeholder="请输入手机号" type="text" onkeyup="this.value=this.value.replace(/\D/g,‘‘)" clearable maxlength="11" > </el-input>