elementUI表单提交定位到错误的地方

export default {
  methods: {
    /**
     *表单提交定位
     *
     * @return {*}
     */
    mixinsFormScrollIntoView() {
      this.$nextTick(() => {
        const isError = document.getElementsByClassName('is-error');
        isError[0].scrollIntoView({
          // 滚动到指定节点
          // 值有start,center,end,nearest,当前显示在视图区域中间
          block: 'center',
          // 值有auto、instant,smooth,缓动动画(当前是慢速的)
          behavior: 'smooth'
        });
      });
    }
  }
};

  submit() {
      // 自组件提交数据
     
      Promise.all([
       result1,
       result2,
       result3
      ]).then(([result1, result2, result3]) => {
        this.$confirm(`确定要提交吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async() => {
          try {
            const params = {
              ...result1,
              ...result2,
              ...result3
            };
         // 请求接口
            await this.xxx(params);
          } catch (error) {
            console.log(error);
          }
        });
      }).catch(() => {
        this.mixinsFormScrollIntoView();
      });
    },
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容