I implemented pagination for the gallery on my website following this tutorial. Problem is that unlike the pagination on the website linked above, my webpage refreshes after a new page number is clicked. That is not what I want to happen.
I want the webpage to stay in the same position, the same way it is on the tutorial. Here is a fiddleJS of how my gallery looks. Unfortunately, since the new pages lead to new URLs and the page refreshes, it leads to а 404 error on fiddleJS but I think it is sufficient to get the idea of what I have done so far.
Code from the fiddleJS:
<div class="container text-center" id="app">
<h1 class = "mb-3">Gallery</h1>
<div class="img-gallery">
<div v-show="currentPage == 1" class="row">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
</div>
<div v-show="currentPage == 2" class="row">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
</div>
<div v-show="currentPage == 3" class="row">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
<img src="https://www.gstatic.com/webp/gallery/1.jpg" class="w-25">
</div>
</div>
<div class="mt-2 mt-sm-3 d-flex justify-content-center">
<b-pagination-nav
v-model="currentPage"
:link-gen="linkGen"
:number-of-pages=3
limit=7
use-router>
</b-pagination-nav>
</div>
</div><!-- container -->
<script>
new Vue({
el: '#app',
data: {
currentPage: ''
},
methods: {
linkGen(pageNum) {
return `${pageNum}`
}
}
})
</script>
Reading the tutorial, what I thought I should do is add use-router to the tag, however, the addition of it did not change anything.