Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vue show next 10 items when press button

I’m trying to do load more function. When load more button is clicked show next 10 hidden items in v-for allCategories loop.

<template v-for="(category, i) in allCategories">
            <v-col :key="i" v-show="i <= 10" class="col-6 col-sm-4">
              <v-checkbox
              dense
              color="black"
              :label="category.title"
              :value="isCategoryChecked(category.id)"
              @click="() => selectCategory(category.id)"
            />
            </v-col>
          </template>

load more button

<v-btn color="black white--text"
   @click="showMoreCategories"
    :loading="loading">
    {{ $t('general.loadMore') }}
</v-btn>

showMoreCategories function

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

showMoreCategories() {

  }

How do i implement this?

>Solution :

Assuming your variable allCategories contains all the categories you could possibly want (i.e. you don’t have to fetch additional categories from a server or local store) then you can replace v-show="i <= 10" with v-show="i <= numberOfCategoriesToShow". Where numberOfCategoriesToShow is a new variable you have defined and initially set to 10.

Then your showMoreCategories function would look like this

showMoreCategories() {
   this.numberOfCategoriesToShow += 10;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading