Skip to content

Instantly share code, notes, and snippets.

@Yang03
Created February 11, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yang03/763b81fd6a8da38e20d0587c18127715 to your computer and use it in GitHub Desktop.
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
Copy link
Author

Yang03 commented Feb 11, 2018

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

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