<template><div><el-form :rules="rules" :model="Form"
>
<el-form-item label="联系电话" prop="vesselTelnum"
><el-input
v-model="Form.Telnum"
placeholder="联系电话"
></el-input></el-form-item
>
</el-form></div></template>
<script>
export default {
created() {
},
data() {
var checktelnum = (rule, value, callback) => {
var reg = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/;
if (!value) {
return callback(new Error("电话不能为空"));
}
setTimeout(() => {
if (value == "" || value == undefined || value == null) {
callback();
} else {
if (!reg.test(value) && value != "") {
callback(new Error("请输入正确的电话号码或者固话号码"));
} else {
callback();
}
}
}, 1000);
};
return{
Form:{Telnum:"",}
rules:{
Telnum :[{validator:checktelnum,trigger:"blur",required:true,}]
}
}
}
</script>
最终可以通过checktelnum里面的判断进行输入分析