New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapGetters 辅助函数,将一个 getter 属性另取一个名字 #1452

Closed
dinglittle opened this Issue Nov 20, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@dinglittle

dinglittle commented Nov 20, 2018

Version

3.0.1

Reproduction link

https://vuex.vuejs.org/zh/guide/getters.html

Steps to reproduce

Vuex 官方 链接所示 mapGetters 辅助函数,将一个 getter 属性另取一个名字 , 示例代码

What is expected?

mapGetters({
  // 把 `this.doneCount` 映射为 `this.$store.getters.doneTodosCount`
  doneCount: 'doneTodosCount'
})

What is actually happening?

修正

...mapGetters({
  // 把 `this.doneCount` 映射为 `this.$store.getters.doneTodosCount`
  doneCount: 'doneTodosCount'
})
@ktsn

This comment has been minimized.

Member

ktsn commented Dec 2, 2018

The example code does not need to have object spread operator since it just shows the example of its argument.
In fact, there are some cases we can use it without object spread operator:

export default {
  computed: mapGetters({
    doneCount: 'doneTodosCount'
  })
}

@ktsn ktsn closed this Dec 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment