<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm">
<el-form-item prop="tel">
<el-input v-model.number="ruleForm.tel" placeholder="请输入11位手机号码" class="inputPhone"/>
</el-form-item>
</el-form>
data() {
var checkTel = (rule, value, callback) =>{
if (!value) {
return callback(new Error('手机号不能为空'));
} else {
const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
if (reg.test(value)) {
callback();
} else {
return callback(new Error('请输入正确的手机号'));
}
}
};
return {
ruleForm: {
tel:'',
},
rules: {
tel:[
{
validator: checkTel,
trigger: 'blur'
}
],
}
}
}