我是靠谱客的博主 爱笑鱼,这篇文章主要介绍antd表单验证,自动跳转到未填写的位置,现在分享给大家,希望可以做个参考。

 // 验证表单
      this.$refs.componentForm.$refs.form.validate((valid) => {
        if (valid) {
          //验证通过
        } else {
            //验证不通过
          this.$message.error('请检查表单是否填写完整')
           this.$nextTick(()=>{
              this.scrollToError()
            })
        }
      })
// 定位未填写的表单
    scrollToError() {
      let error_div = document.body.querySelector('.ant-form-explain')
      this.$nextTick(() => {
        if (error_div)
          document.body.querySelector('.ant-form-explain').scrollIntoView({ behavior: 'smooth', block: 'center' })
      })
    },

最后

以上就是爱笑鱼最近收集整理的关于antd表单验证,自动跳转到未填写的位置的全部内容,更多相关antd表单验证,自动跳转到未填写内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部