scrollIntoView()
说明:调用它的元素滚动到浏览器窗口的可见区域。
this.$refs["form"].validate((valid) => {
if (valid) {
return;
} else {
this.$nextTick(() => {
let isError = document.getElementsByClassName("is-error");
isError[0].scrollIntoView({
// 滚动到指定节点
// 值有start,center,end,nearest,当前显示在视图区域中间
block: "center",
// 值有auto、instant,smooth,缓动动画(当前是慢速的)
behavior: "smooth",
});
return;
});
}
});