// 表单校验 checkBasicForm() { return new Promise((resolve) => this.$refs.basicForm.validate((valid, object) => { if (valid) {
// 校验通过 resolve(this.formatterForm()) } else { // resolve(false)
// 校验未通过,滚动到指定位置 let str = [] for (let key in object) { object[key].map((item) => { str.push(item.message) }) let dom = this.$refs[Object.keys(object)[0]] if (Object.prototype.toString.call(dom) !== '[object Object]') { dom = dom[0] break // 结束语句并跳出语句,进行下个语句执行 } // 定位代码 dom.$el.scrollIntoView({ block: 'center', behavior: 'smooth' }) } } }) ) },
注意给form-item加ref
<a-form-model-item ref="parentId" label="上级项目" prop="parentId" v-bind="parentCol" ></a-form-model-item>
标签:el,Object,form,dom,object,校验 From: https://www.cnblogs.com/hwy6/p/16845267.html