To start our component, we will use the Vue project with Vue-CLI that we used in the 'Creating and understanding the Vuex state' 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, add Router and Vuex as required features, as indicated in the 'How to do it...' section of the 'Creating a simple Vuex store' recipe.
Now we create a Vuex mutation and base type for the mutations:
- Create a new file called types.js in the user folder inside the src/store folder, and open it.
- In this file, we will create an export default JavaScript object, with a group of keys that will be the names of our mutations. Those keys will be LOADING, ERROR, SET_USER_LIST, SET_USER_DATA, UPDATE_USER, and REMOVE_USER:
export default {
LOADING: 'LOADING',
ERROR: 'ERROR',
SET_USER_LIST:...