spatie / vue-table-component

A straight to the point Vue component to display tables
http://vue-table-component.spatie.be
MIT License
588 stars 149 forks source link

Behavior while loading asynchronous data #152

Closed ethanclevenger91 closed 6 years ago

ethanclevenger91 commented 6 years ago

I'd like to give this thing a spinner or something while it's loading. Is there some way to v-if for empty data and render something else in the meantime?

hnassr commented 6 years ago

You can do something like this:

<i v-if="loading" class="fa fa-spin fa-spinner fa-3x"></i>

and fetchData method:

async fetchData({ page, filter, sort }) {
    this.loading = true;
    const response = await axios.get('/clients', {params: { page, filter, sort }});
    this.loading = false;
    return {
        data: response.data.clients.data,
        pagination: {
            currentPage: response.data.clients.current_page,
            totalPages: response.data.clients.last_page
        }
    };
}
spatie-bot commented 6 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.