To start our component, we will use the Vue project with Vue-CLI that we used in the 'Creating and understanding the Vuex mutations' recipe, or we can start a new one.
To start a new one, open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> vue create vuex-store
Choose the manual features, and add Router and Vuex as needed features, as indicated in the 'How to do it...' section of the 'Creating a simple Vuex store' recipe.
In the following steps, we will create the Vuex getters:
- Create a new file called getters.js in the src/store/user folder.
- Create a new function called getUsersList, and return the state.data.usersList property:
function getUsersList(state) {
return state.data.usersList;
}
In a getter function, the first argument that the function will receive will be always the current state of the Vuex store.
- Create a new function called getUserData, and return the state.data...