Questions about toRaw() #11623
Replies: 2 comments 1 reply
-
You might want to look at https://developer.mozilla.org/en-US/docs/Web/API/structuredClone or use one of the common deepClone functions from packages such as lodash-es or similar. |
Beta Was this translation helpful? Give feedback.
-
There are two more solutions to your problem. The straightforward one - detach reactivity altogether with data2.user = JSON.parse(JSON.stringify(data1.user)) The other solution is to use a twist of a Memento pattern that creates the |
Beta Was this translation helpful? Give feedback.
-
As shown in the code below, I want to assign the data from data1 to data2, and I want to use the toRaw function so that data1 and data2 are just copies without being linked. However, when I change the value of data2, the value of data1 is also changed. Why is that happening?
This demo is based on a real issue. I have a table, and I want to edit the data of one row. When I click the edit button, the data of that row is displayed in a dialog box. After making changes, an AJAX call is made. In this case, I only need the row data for display purposes, and I don't want the table's data to be changed when editing the data
Beta Was this translation helpful? Give feedback.
All reactions