scrollIntoView()
查询方法多数为给各el-form-item设置ref,然后使用$el.scrollIntoView()进行滚动。由于表单内容实在过多,故不选择该方法。
为form注册ref并打印其父组件的refs对象,发现子节点children也包含其中
展开children发现和父级一样拥有$el,则说明可以使用子级的scrollIntoView()。
下一个问题在于:定位到产生提示的子级
可以使用isRequired和validateState进行判断
validateState为‘error’时代表失败
const scrollItem = this.$refs.DetailForm.$children.filter(item => item.validateState && item.validateState == 'error')[0];
scrollItem.$el.scrollIntoView({ block: 'center', behavior: 'smooth' });
});