[Vuejs]-Why does altering a property of a child component affects the parent?

0👍

I found the answer in the documentation:

Note that objects and arrays in JavaScript are passed by reference, so if the prop is an array or object, mutating the object or array itself inside the child component will affect parent state.

The solution was to deep clone the prop value (I used lodash) into a new variable (and then $emit it as mentioned in the question)

Leave a comment