简体   繁体   中英

What is the best way to use data in Vue.JS between components

EveryOne!

I have a front of aplication in Vue.JS in which people are singing in. with axios. If login is ok - Vue application gets User Object like this server

{"_id" : ObjectId("5acf15a9d1bec12bdc4c2243"),
"role" : "admin",
"email" : "dev0@jland.info",
"name": "Pavel"}

I want to store this somewhere in Vue.JS but I got a lot of components (.vue) in my project I what to use data as well in all components throught whole application

Use Vuex.

https://vuex.vuejs.org/en/intro.html

It's a plugin you incorporate into your Vue app. It provides global state management so you can share data through your components without losing reactivity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM