[Vuejs]-Pass array of objects to a data object in Vue specs

0👍

The data property of an object represents its internal state and it is kind of weird to try to assign values from outside.

I would suggest to use properties (props). Props are values send from the outside to the component.

If properties doesn’t work for you, then you could make a method in your component, that method will receive your new values and assign those values to internal data. From the outside instead of assigning directly the values, you will call a method to do that.

0👍

Vue 3 wraps reactive data in proxies. Therefore your data might look like this, with getters and setters.

Try console.log(JSON.stringify(YOUR_ARRAY)) to see if your data is as expected.

You did not provide enough code, to know exactly why your data is undefined, where you expect it to be available.

Rememeber that props should be accessed using this.$props.PROPNAME inside a child component.

Leave a comment