1

克隆具有圆形结构的primeNG 树对象的最有效方法是什么?我做过类似的事情

  1. obj = JSON.parse(JSON.stringify(o)); //但是 JSON.stringify() 不适用于圆形结构。
  2. var newObject = jQuery.extend(true, {}, oldObject);
  3. let newObject = this.copyObj(oldObject); copyObj(obj) { // This is done because we need a copy of list, without this code it will copy a ref which will update file badges on create screen without add button click return [obj[0]]; }
  4. let newObject = Object.assign({}, oldObject);

但是所有这些方法都是Copy Object ByReference而不是ByValue

4

0 回答 0