【问题标题】:How to mix namespaced mapGetters with global getters?如何将命名空间的 mapGetter 与全局 getter 混合使用?
【发布时间】:2018-07-01 06:43:28
【问题描述】:

我已经命名了我的一个 Vuex 模块,但我不确定在这种情况下我应该使用什么语法。

我目前正在使用这种语法,其中dealfilters 是我的命名空间模块。

...mapGetters('dealfilters', [
    'dealCount',
    'pending',
    'arrival',
    'nights',
    'tag',
    'sortOptions'
])

我将如何再次为这个 mapgetter 助手添加一个全局 getter?甚至在 mapGetter 中调用多个不同的命名空间模块?

【问题讨论】:

  • 两次调用mapGetters是什么问题?

标签: vue.js vuejs2 vue-component vuex


【解决方案1】:

两次使用 mapGetters 并没有错。如果您不想这样做,您也可以使用namespace/getterName 字符串。

...mapGetters([
  'namespace_foo/thing',
  'namespace_foo/bazzle',
  'namespace_bar/thing',
  'not_namespaced_this_should_work_but_i_dont_know',
])

【讨论】:

    猜你喜欢
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-16
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    相关资源
    最近更新 更多