//滚动到选中定位的位置
selectedRegion() {
// 通过Id获取到对应的dom元素
const node = document.getElementById(this.sertCurrnetKey)
setTimeout(() => {
if (node) {
this.$nextTick(() => {
// 通过scrollIntoView方法将对应的dom元素定位到可见区域 【block: 'center'】这个属性是在垂直方向居中显示
node.scrollIntoView({
behavior: 'smooth', // 平滑过渡 值有auto、instant,smooth,缓动动画(当前是慢速的)
block: 'center',
})
})
}
}, 100)
},
// 滚动条滚到需要校验的位置
setTimeout(() => {
const el = document.querySelector(
'.ant-form-item-has-error',
);
if (el) {
el.scrollIntoView({
behavior: 'smooth',
block: 'center',
});
}
}, 100);