浏览代码

throw error when user tries to replace root state

Evan You 9 年之前
父节点
当前提交
7afede5d06
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/index.js

+ 4 - 0
src/index.js

@@ -40,6 +40,10 @@ export default class Vuex {
     return this._vm._data
   }
 
+  set state (v) {
+    throw new Error('[vuex] Vuex root state is read only.')
+  }
+
   /**
    * Dispatch an action.
    *