Vue components often interact with a global state tree using Vuex. This allows components to access and modify shared data.
Accessing State via mapState
Components use mapState to map global state properties to local component properties, shortening the code. For example, mapState('visitUserInfo', ['isTaskUser']) allows the component to use this.isTaskUser instead of this. $store.state.visitUserInfo.isTaskUser.
Modifying State via commit
To change the state, components call this.$store.commit(mutationType, payload). This triggers a mutation function that updates the state tree.
Accessing State via mapGetters
mapGetters is used to map computed properties from the Vuex store to the component, such as permission checks (e.g., canCopy).