[Vuejs]-Revert changes to array in Vue

2๐Ÿ‘

โœ…

If you give a working fiddle I can show you what happened.

Basically, because you are modifying the same array object. this.originals refers to the same array as this.items

Slice returns a shallow copy of the object. You should either take a deep copy or your revert should be the one initializing the object.

this.items.pop();
will remove the items from this.originals as well.

๐Ÿ‘คuser1496463

Leave a comment