A
A
Alexey Sklyarov2019-01-09 15:34:58
Vue.js
Alexey Sklyarov, 2019-01-09 15:34:58

How to render a component only after receiving data from a VUEX getter?

There is a component with a computed data property:

computed: {
      data(){
        return this.$store.getters['currency/getCapitalization'];
      }
    },

The component template displays: {{data.capitalization | comma | dollar}}, but during the first render (then the second one apparently happens immediately, since the data in the getter appears, an error appears:
[Vue warn]: Error in render: "TypeError: Cannot read property 'capitalization' of undefined".
, which refers to {{data.capitalization | comma | dollar}}, the error is not critical, apparently, since everything is re-rendered immediately and works in the future, but I would like such errors not to glare in the console, how can I fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-01-09
@0example

You don't need to render the element you're rendering data.capitalization to while there's no data: v-if="data".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question