Answer the question
In order to leave comments, you need to log in
How to correctly implement a conditional preloader in vue?
There is such a code
<template>
<div v-if="$store.getters.list">
<List>появится после выполнения асинхронного запроса</List>
</div>
<div v-else>
<Preloader v-if="$store.state.loader">индикатор загрузки</Preloader>
<div v-if="!$store.state.loader">Не удалось загрузить данные с сервера</div>
</div>
</template>
<Preloader v-if="$store.state.loader">индикатор загрузки</Preloader>
is a separate component with a loading indicator that is shown at the beginning of the request and hidden after the request is completed. That is, state vuex has a loader property that changes to true / false depending on whether the request to the server has completed or not<div v-if="!$store.state.loader">Не удалось загрузить данные с сервера</div>
- this block just contains the information that should be shown if nothing came in the request / the request was not executed. <div v-else>
<Preloader v-if="$store.state.loader">индикатор загрузки</Preloader>
<div v-if="!$store.state.loader">Не удалось загрузить данные с сервера</div>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question