这个问题是我在提交测试的时候,我们测试工程师提出了的bug,做了这么久第一次知道还有这效果,话不多说,上代码
dataFormSubmit() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
//验证通过执行的操作
} else {
//验证不通过回滚到不通过的第一个位置
this.$nextTick(() => {
let isError = document.getElementsByClassName('is-error')
isError[0].scrollIntoView({
block: 'center',
behavior: 'smooth',
})
})
}
});
},
看看效果:
回滚