I have users in a Vuex module
/users.js
export const state = () => ({
users: [{
// users go here
}]
});
I can access the values with
$store.users.users
but I would like to map or alias to just this.users
with mapstate, is this possible.
Failing that can I get rid of the 'double users'?
Yes:
computed: {
...mapState('users', ['users'])
}
The first argument to mapState
references the users
module, and the 2nd argument is an array of properties to map, in this case the users
property.