Open hckhanh opened 4 months ago
Hello! It looks like you're trying to use the function before the component is mounted:
form.value?.setErrors(/* ... */); // This will be undefined since the component is not mounted
onMounted(() => {
form.value.setErrors(/* ... */); // This will be defined
});
See: https://vuejs.org/guide/essentials/template-refs.html#accessing-the-refs
The onSubmit function is called after the component is mounted
Can you send me a reproduction using Stackblitz so I can have a look? I can't reproduce the issue from the documentation's example
hi, I run in the same problem. do your response have a path? My solution was to set it manually
const swwError = ref(false); //somethingWentWrongError
const form = ref();
const onSubmit = async (event) => {
try {
const data = await authStore.create(event.data);
router.push("/");
} catch (error) {
//email exists already
if (error.response.status === 422) {
form.value.setErrors([
{
message: error.response.data.message,
path: "email",
},
]);
} else {
// For all other errors, a standard error message is displayed at the top of the form
swwError.value = true;
}
}
This issue is stale because it has been open for 30 days with no activity.
Environment
Version
3.12.2
Reproduction
I try to follow this example on docs:
Description
Is there anything is out of dated compare to the latest version of nuxt?
Additional context
Logs
No response