search

Home  >  Q&A  >  body text

What is the most efficient way to distribute data in a Vue3 application?

Is there a recommended way to propagate data through vue components? What I want to do is get data from the backend once and propagate it to various locations in my project, but I can't find the right strategy.

sessionStorage: Works great and resets when refreshing/closing the window, but once you need to create a target="_blank" anchor tag it doesn't.

P粉413307845P粉413307845314 days ago544

reply all(1)I'll reply

  • P粉022140576

    P粉0221405762024-03-27 12:18:55

    There are some good arguments as to why Vuex is better than local storage:

    https://www.quora.com/What-is-the-benefit-of-using-Vuex-over-LocalStorage-to-store-the-state-of -Application in Vue-js program

    You can also try composable items. They are reusable functions (similar to mixins) in composition-api (in vue2 the composition-api plugin is required, in vue3 it is built-in). It can also be where you store your data

    reply
    0
  • Cancelreply