[Vuejs]-Push object to array, composition api

1👍

Pushing machineInfo.value keeps the reference to the original object in the array. You’ve just made a shallow copy. Any updates to machineInfo.value causes the value in the array to also update. You need to deep copy first before pushing.

chosenMachines.push({...machineInfo.value})

There are many other ways to deep copy, depending on your data one method may be more suitable than another.

👤yoduh

Leave a comment