//el-form绑定ref
<el-form ref="form" :model="formData" :rules="rules">
<el-form-item label="联系电话:" prop="tel">
<el-input v-model="tel" placeholder="请输入" />
</el-form-item>
</el-form>
data() {
return {
tel
: '',
formData
: {
tel
: '',
},
rules
: {
tel
: [{ required
: true, message
: '请输入手机号码', trigger
: ['change', 'blur'] }],
},
}
},
this.$refs
['form'].validate(valid
=> {
if (valid
) {
} else {
this.$nextTick(() => {
let isError
= document
.getElementsByClassName('is-error')
isError
[0].scrollIntoView({
block
: 'center',
behavior
: 'smooth',
})
})
return
}
})
转载请注明原文地址:https://tech.qufami.com/read-7420.html