lokyoung / vuejs-paginate

A Vue.js(v2.x+) component for creating pagination.
MIT License
779 stars 171 forks source link

How hide pagination component, when it has only 1 page? #106

Open PetroGromovo opened 5 years ago

PetroGromovo commented 5 years ago

Hello, In "vue": "^2.5.17" app working with vuejs-paginate("^2.1.0") component I found that if there are only data for 1 page, I got such component : https://prnt.sc/nwbeau If there is a way not to show pagination component, when it has only 1 page?

Thanks!

vukasinovic commented 5 years ago

Hello @PetroGromovo You can use v-if to show/hide paginate depending on page-count attribue, example:

<div v-if="totalNumOfPages > 1">
     <paginate
         v-model="currentPage"
         :page-count="totalNumOfPages"
          ...                 
         :prev-class="'page-link'"
         :next-class="'page-link'">
</paginate>
</div>

For this you need to have total pages provided from backend etc. I stored that in totalNumOfPages variable and use v-if on parent component of component. Hope that helps