A
A
Alexey Sklyarov2018-09-10 12:14:22
Vue.js
Alexey Sklyarov, 2018-09-10 12:14:22

How to run any function while receiving data from the server?

The vue component receives data once a minute, after which it is updated in the component itself. I want to make a spinner on the block when the data is updated, then when the new data is displayed, hide it.
That is, the idea is this:
1. the first render of the component with data occurs
2. the method is executed through:setInterval(func,60000);

requestData: function (currency) {
            // console.log(currency);
            axios
              .get('/api/capitalization/' + currency)
              .then(response => {
                // Пишем parse, потому что из базы берется сразу JSON с слешами "\"
                this.info = JSON.parse(response.data);
                console.log(this.info);
              });
          }

I don’t understand how it is possible to set the block update animation before execution, and after the data is received, remove this block?
Or is it all simple and correct enough to use "flags"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-09-10
@0example

isLoadingLet the flag take values ​​either falseor true(when loading is in progress).
Show/hide spinner viav-if="isLoading"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question