1
0
Evan You 9 жил өмнө
parent
commit
3fff85fdfe
1 өөрчлөгдсөн 12 нэмэгдсэн , 0 устгасан
  1. 12 0
      src/index.js

+ 12 - 0
src/index.js

@@ -129,6 +129,18 @@ export class Store {
     this._setupModuleMutations(modules || this._modules)
   }
 
+  /**
+   * Replace entire state tree.
+   */
+
+  replaceState (newState) {
+    const state = this._vm._data
+    const clone = deepClone(newState)
+    Object.keys(clone).forEach(key => {
+      state[key] = clone[key]
+    })
+  }
+
   /**
    * Attach sub state tree of each module to the root tree.
    *