Let's store some data in a vue app | vue save data
Firstweneedtoaddvuextoourapp.npminstallvuexCool,butletswaitasecond.Astatestore,whatissuchathing.Inourappweareputtingallthedatainacentralizedstore,astorecanlooklikeanythingandisjustandobject.conststate={};JustanobjectCool,anobject.Withthiswecanadddataandgetdataineveryvuecomponentwemake.Andifwemakesomethinginonecomponent,wecanautomaticallyfetchthedataineverycomponentweuse.Thiscanbeuseful,andwillgettothat.
First we need to add vuex to our app.
npm install vuexCool, but lets wait a second. A state store, what is such a thing. In our app we are putting all the data in a centralized store, a store can look like anything and is just and object.
const state = {};Just an object
Cool, an object. With this we can add data and get data in every vue component we make. And if we make something in one component, we can automatically fetch the data in every component we use. This can be useful, and will get to that.