[Vuejs]-Objects gets empty in VueJS Component

0👍

It’s a bit hard to tell for me without running the code, but I’ve noticed something that may be related.

I see that you’re overwriting the formElements prop here:

a.config_elements.error = this.error[a.field_name][0];

Vue usually gives you a warning that you can’t do that, but maybe because it’s abstracted through the computed it’s not doing so.

If you want to extend the data for use in the child component, then it’s best to do copy of the object (preferably a deep copy using computed, which will allow you to have it dynamically updated)

because config_elements is an object, when you add error variable you are likely triggering an observer, that may be clearing the data in the parent.

Anyway, it’s just a guess, but something you may want to resolve anyway.

👤Daniel

Leave a comment