[Vuejs]-V-model doesn't recognize the property passed if textarea is empty

2👍

So the problem is that this line sets this.errors to undefined:

this.errors = e.errors

In your template you’re then trying to access errors['content'], which will fail. You can’t access a property of undefined.

I’m not exactly sure what that line is trying to achieve, perhaps e.errors is not the correct property? The key thing is that you have to ensure that this.errors remains an object. e.g.

this.errors = e.errors || {}

This will make the console error go away but to fix it properly would require some understanding of exactly what the value should be when e.errors is undefined.

Incidentally, there’s no need to write errors['content'] in your template. You can just use errors.content.

1👍

I think it comes from errors, try to change errors for an array errors: [], in case that doesn’t work try adding a condition for errors before every condition of errors for example v-if="errors && errors['content']"

👤men32z

Leave a comment