浏览代码

Use deepCopy to copy the options.data

zhixin 5 年之前
父节点
当前提交
3c8fef3f54
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 1 1
      src/bootstrap-table.js
  2. 7 0
      src/utils/index.js

+ 1 - 1
src/bootstrap-table.js

@@ -407,7 +407,7 @@ class BootstrapTable {
     } else if (type === 'prepend') {
       this.options.data = [].concat(data).concat(this.options.data)
     } else {
-      data = data || [...this.options.data]
+      data = data || Utils.deepCopy(this.options.data)
       this.options.data = Array.isArray(data) ? data : data[this.options.dataField]
     }
 

+ 7 - 0
src/utils/index.js

@@ -371,5 +371,12 @@ export default {
       }
     }
     return false
+  },
+
+  deepCopy (arg) {
+    if (arg === undefined) {
+      return arg
+    }
+    return $.extend(true, Array.isArray(arg) ? [] : {}, arg)
   }
 }