Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 react-hook-form,我在一页中有两种不同的形式。当我提交至少一个表单时,我想隐藏两种表单中的所有错误消息,例如在演示中,我想在提交电子邮件表单时隐藏所有错误消息,反之亦然,但它不起作用,任何帮助请?
要隐藏错误,您需要将它们设置为空字符串。
如果要在提交任一表单时清除所有错误,请将错误设置为onSubmit函数内的空字符串:
onSubmit
const onSubmitEmail = data => { setInput({ fname: "Bill", age: 10, email: "bjames@gmail.com" }); // This will hide the error for First Name field errors.fname = ""; };