iview Form自動跳轉到校驗不經過的地方

需求:帶有滾動條的彈窗提交form時,滾動條滾動到form校驗未經過的地方。this

代碼:orm

handleSubmit(name) {
  this.$refs[name].validate((valid) => {
    if (!valid) {
      const srollHeight = [0, 100, 200, 300];
      for (let i in this.$refs.formCustom.$children) {
        if (this.$refs.formCustom.$children[i].validateState !== 'success') {
          document.querySelector('.layhomework .ivu-modal-body').scrollTop = srollHeight[i];
          break;
        }
      }
    } else {
      this.createHomework();
      }
    });
},
相關文章
相關標籤/搜索