merge objects into plug-in method of use Lodash

Installation lodash dependency:

Installation npm: 
    CNPM lodash I - S 

Yarn command to install: 
    Yarn the Add lodash

 

 

 

Ran and eggs:

// lodash introduced 
Import _ from  ' lodash ' ; 


// use of the js vue
const result = _.assign (); // assign only point out the method, the method can not merge point out, that there is no merge which plug lodash method


 

 

 

 

 

In fact, the effect is the same with the assign method, but the depth of the copied object in question. Later I found this: https://www.npmjs.com/package/lodash.merge

Want to use the merge method solution is as follows:

1 , the install command: 
CNPM I - Save lodash.merge 


2 , used in the js:
     var Merge the require = ( ' lodash.merge ' ); 

    var Result = Merge (Object 1, Object 2);

 

Guess you like

Origin www.cnblogs.com/spll/p/12084278.html