This article mainly introduces the relevant information about vue deep copy. It is very good and has reference value. Friends who need it can refer to it
The Object.assign() method is used to assign all enumerable attributes. Values are copied from one or more source objects to the target object. It will return the target object.
const object1 = { a: 1, b: 2, c: 3 }; const object2 = Object.assign({}, object1); console.log(object2.c); // expected output: 3
Or use
obj=JSON.parse(JSON.stringify(this.templateData)); //this.templateData是父组件传递的对象
Applicability
When an abstract model has two aspects, one of which depends on the other. Encapsulating the two in independent objects allows them to be changed and reused independently
When one object changes, other objects need to be changed at the same time, but we don’t know how many objects need to be changed.
When an object must notify other objects, but it does not know who the specific object is. In other words, you don't want these objects to be tightly coupled.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to get your own properties by clicking in vue.js2.0
In vue.js How to use modifier .self?
Explain in detail how to use this.$emit in vue.js
How to implement the password display and hide switching function in vue
How to use parent component to call child component events in Vue
Use $http to implement asynchronous uploading of Excel files in angularjs
The above is the detailed content of How to treat deep copy in vue. For more information, please follow other related articles on the PHP Chinese website!