How does the store work and what is so special about it?

The Vuex store contains essentially two things: state and mutations. State is an object that represents the initial state of the application data. Mutations is also an object containing action functions that affect the state. Vuex store is just a plain JavaScript file that exports these two objects and tells Vue to use Vuex (Vue.use(Vuex)). Then it can be imported into any other component. If you import it in the main App.vue file and register the store on the Vue application initialization, it is passed to the whole children chain and can be accessed through the this.$store variable. So, very roughly, in a very simplified way, we would create a store, import it in the main app, and use ...

Get Learning Vue.js 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.