Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Component] [form] Logical problem with validate method on el-form #10250

Closed
coderPeng3yang opened this issue Oct 26, 2022 · 1 comment · Fixed by #10255
Closed

[Component] [form] Logical problem with validate method on el-form #10250

coderPeng3yang opened this issue Oct 26, 2022 · 1 comment · Fixed by #10255

Comments

@coderPeng3yang
Copy link

Bug Type: Component

Environment

  • Vue Version: 3.2.41
  • Element Plus Version: 2.2.19
  • Browser / OS: win10
  • Build Tool: Vite

Reproduction

Related Component

  • el-form

Reproduction Link

Element Plus Playground

Steps to reproduce

后台管理

确定 重置
<script setup> import { ref } from "vue"; import { Avatar } from "@element-plus/icons-vue"; const loginData = ref({ name: "", password: "", }); const formRef = ref(); const rules = { name: [ { required: true, message: "账号未填写", trigger: "blur", }, ], password: [ { required: true, message: "密码未填写", trigger: "change", }, ], }; // 登录 const loginBtn = () => { formRef.value.validate((valid) => { console.log(valid); if (valid) { asdasdasdasdasfadasdas; } else { return false; } }); }; // 重置 const reset = () => { formRef.value.resetFields(); }; </script> <style lang="less" scoped></style>

What is Expected?

console.log(valid) executes once when I click log in

What is actually happening?

console.log(valid) executes twice when I click log in without notifying the code that there is a problem

Additional comments

Engilsh
Why is the validate method on the el-form designed like this? if there is a problem with the code block in the IF, the validate method will be executed twice, instead of directly telling the developer that there is a problem with the code, will this lead to the logic inconsistency and affect whether the user is notified of the problem or the problem with the code

Chinese
el-form上的validate方法为什么这样设计呢,如果if里面的代码块存在问题的时候会出现执行两次validate的方法,并不是直接告诉开发者出现代码问题了,这样会不会导致逻辑的不通顺,影响通知用户是否是自己的问题还是代码的问题

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant