Skip to content

Instantly share code, notes, and snippets.

@Yang03
Created February 11, 2018 10:36
Show Gist options
  • Select an option

  • Save Yang03/763b81fd6a8da38e20d0587c18127715 to your computer and use it in GitHub Desktop.

Select an option

Save Yang03/763b81fd6a8da38e20d0587c18127715 to your computer and use it in GitHub Desktop.
mapGetters vs mapState
...mapGetters({
x1: 'widgets/x1'
}),
...mapState('widgets', ['xx'])
state = {
xx: 0
}
getters = {
x1: state => state.xx + 1
}
this.x1 // 2
this.xx //0
@Yang03

Yang03 commented Feb 11, 2018

Copy link
Copy Markdown
Author

mapState 是初始属性,mapGetters 计算属性

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