Answer the question
In order to leave comments, you need to log in
How to make pagination in nuxt.js given ssr?
Hello! For the first time I encountered the development of an online store on Nuxt.js. I would like to know how to quickly and correctly make pagination?
For the first time I encountered the development of a SPA for an online store. And ran into the issue of pagination. How to do pagination? Perhaps there are ready-made ssr plugins?
Answer the question
In order to leave comments, you need to log in
If everyone understands correctly, then
async asyncData(ctx) {
let products = await ctx.app.$api.products(ctx.params.slug, ctx.query);
return {
products: products.data,
total: products.total,
perPage: products.per_page,
}
watch: {
'$route'() {
this.getProducts();
},
},
getProducts() {
this.$api.products(this.$route.params.slug, this.$route.query).then(products => {
this.products = products.data;
this.total = products.total;
this.perPage = products.per_page;
});
},
this.$router.push({
query: {
...this.$route.query,
page: page,
},
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question