elementui 长表单验证滚动到首个错误位置

路漫漫其修远兮,吾将上下而求索 / 2023-09-02 / 原文

this.$refs['form'].validate(valid => {
    if(valid){
        // 验证通过
        
    } else {
        // 验证失败
        this.$nextTick(() => {
            let isError = document.getElementsByClassName('is-error')
	        isError[0].scrollIntoView({
		        block: 'center',
		        behavior: 'smooth'
	       })
	   })
    }
})