[Vuejs]-Vue Reactivity updating the wrong object/proxy

0👍

Okay, so apparently (I think):

if(props.selectOptions.length > 0) state.options = props.selectOptions;

Vue thinks that because the props.selectOptions has the same object, it could be modified by any component in the same way at the same time.

Making a deep copy of the object solves the problem:

if(props.selectOptions.length > 0) state.options = JSON.parse(JSON.stringify(props.selectOptions));

Leave a comment