Skip to content Skip to sidebar Skip to footer

Vuex Dispatch Doesn't Return Data In View

I cannot get my data from vuex and use them in all views, but i do see their success results in network tab. screenshots network tab console Code store.js state: { currency:

Solution 1:

Method Currency is already defined as props. remove this in your code.

props:['currency']

Ten call this currency in your component like this

<div>
   {{this.$store.getters.currency.name}}
</div>

to surely display the currency, what I did is to put first a condition to check if it is was already loaded. like this

<div v-if="$store.getters.currency">
      {{this.$store.getters.currency.name}}
  </div>

or declare a new variable in your data like

data() {
   return {
       currency: this.$store.getters.currency.name
   }
}

now you could call it this way

<div v-if="$store.getters.currency">
     {{currency.name}}
</div>

Post a Comment for "Vuex Dispatch Doesn't Return Data In View"