因为手机号码再更新,所以最好的验证办法就是为11位时,不提示格式错误,并且没有使用input框写,所以刚开始有点不知所措。
this.$prompt('请输入手机号码或座机号', '客服电话', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValidator: (val) => {
if (val === null) {
return true;
}
return !(val.length > 11 || val.length < 11)
},
inputErrorMessage: '格式不正确'
}).then(function (action) {
console.log(action);
}).catch(function (cancel) {
console.log(cancel);
})