vuex 模块还需要命名空间吗?

Do vuex modules still require namespacing?

我建立了一个相当大的包含多个模块的 Vuex 项目。

https://vuex.vuejs.org/en/modules.html

要从 search 模块中获取 getter 的示例,可以这样处理 getter:

computed: {
    filters() {
        return this.$store.state.search.filters;
    }
}

因为我需要通过在我的 属性 链中引用 search 属性 来访问模块的状态,我还需要为我的模块命名空间吗?

文档说明如下:

By default, actions, mutations and getters inside modules are still registered under the global namespace - this allows multiple modules to react to the same mutation/action type.

https://vuex.vuejs.org/en/modules.html#namespacing

但是如果模块在其自己的 属性 商店中,这不是模块本身之间可能发生的唯一冲突,可以通过简单的文件命名约定轻松避免这种情况?

我在这里错过了什么?

But if the module is under its own property in the store isn't the only conflict that could happen between modules themselves, which can easily be prevented by a simple naming convention of the files?

不对,你误会了。状态本身是正确命名空间的,但是突变、动作和 getter 仍然在全局级别上收集,因此您可以,例如分派一个动作,来自不同模块的多个动作对其作出反应。

这是默认行为,但好消息是,可以选择命名空间突变、操作和吸气剂:"namespaced: true"。

它记录在这里:https://vuex.vuejs.org/en/modules.html#

向下滚动到 "Namespacing" 部分。