浏览代码

disallow to register the root module by registerModule

ktsn 8 年之前
父节点
当前提交
bb8ba9e457
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      src/store.js

+ 2 - 0
src/store.js

@@ -140,6 +140,8 @@ export class Store {
   registerModule (path, rawModule) {
   registerModule (path, rawModule) {
     if (typeof path === 'string') path = [path]
     if (typeof path === 'string') path = [path]
     assert(Array.isArray(path), `module path must be a string or an Array.`)
     assert(Array.isArray(path), `module path must be a string or an Array.`)
+    assert(path.length > 0, 'cannot register the root module by using registerModule.')
+
     this._modules.register(path, rawModule)
     this._modules.register(path, rawModule)
     installModule(this, this.state, path, this._modules.get(path))
     installModule(this, this.state, path, this._modules.get(path))
     // reset store to update getters...
     // reset store to update getters...