[Vuejs]-Cancel editing function doesn't work in Vue component

0👍

Copying an object to another variable using simple assignation syntax in Vue keeps the two objects linked, so any changes made to one will be made to the other. That’s why when you try to cancel edits using the beforeEditCache, it doesn’t work because the data has been changed in both instances.

To get round this, use the JavaScript Object.assign() method, or Lodash’s cloneDeep function for arrays and nested objects.

Leave a comment