<v-pagination
v-model="pageNumber"
:length="numberOfPages"
color="primary"
totalVisible="5"
class="paginationComponent"
@update:modelValue="changePage()">
</v-pagination>
<script>
export default {
data: () => ({
pageNumber: 1,
})
}
methods: {
init() {
axios({
method: "get",
url: "/products",
params: {
size: 10,
page: this.pageNumber - 1,
},
})
.then((response) => {
console.log('Success');
})
.catch((error) => {
console.error(error);
});
},
changePage() {
console.log(this.pageNumber);
this.init();
},
</script>
I am pretty new to Vue.js. Every time I click on a page number, the exact number is being logged into the console. I am unable to understand how it is recognizing that number. I thought there is a logic in the method which adds or subtracts the number to/from the default pageNumber value. But there's no such thing. With correct pageNumber the api takes care of rest of the work.
Before this process, I tried accessing the text content of the pageNumber element with children elements all the unnecessary weird stuff.
Same as
In
v-paginationcomponent, click page number buttonRecommended