Navigating through pages using Nuxt UI-pagination

Having some trouble with setting up the pagination feature from Nuxt UI. Despite trying to research through documentation and videos, I can't seem to figure out how to connect my data to the component.

<template>
        <div>
            <ul class="p-5">
            <li v-for="creator in creators" class="mb-5"gt;
                <nuxt-link
                :key="creator.id"
                :to="`/creator/${creator.slug}`>
                <div class="creatorCard" :style="{ background: `url(${creator.banner}) center center no-repeat`, backgroundSize: `100% auto` }>
                    <div class="glassEffect">
                        <div class="text pl-5 items-end h-1 pb-2">
                            <p class="font-bold">{{ creator.label }}</p>
                            <p class="italic">{{ creator.ig }}</p>
                        </div>
                    </div>
                </div>
            </nuxt-link>
        </li>
    </ul>
    <div class="pb-4">
        <UPagination :ui="{ wrapper: 'justify-center'}" v-model="page" :page-count="7" :total="creators.length" />
    </div>
</div>
</template>


<script setup lang="ts">
const page = ref(1);

const creators = useCreators();

useHead({
  title: 'Creators',
})
</script>

Answer №1

Connect the meta data to the component properties and incorporate the @click event on the <UPagination> element. Utilize the v-model to retrieve the value from the component and send it to the GET method for data retrieval.

Below is a simple example of how this can be implemented:

<UPagination 
  :ui="{ wrapper: 'justify-center'}" 
  v-model="page" 
  :page-count="meta.per_page" 
  :total="meta.total"
  @click="update"
/>
const page = ref(1);
const creators = useCreators(page.value);
        
function update(){
  const creators = useCreators(page.value);
}
   

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the capabilities of Angular and UIGrid for fetching table information

I have been utilizing Angular along with uigrid, which is an excellent library for displaying data in a tabular format. Everything looks good when displaying the table. However, when I update an item and click on a Save button that triggers a rest service ...

Issue encountered when attempting to locate the file path within the getStaticProps function of an internal page in Next Js

I'm currently implementing a multi-language feature on my Next JS app. Below is the folder structure of my project. https://i.stack.imgur.com/5tD2G.png On the Home page (index page), I successfully retrieved the locales module using getStaticProps: ...

Failed to load JSON data from the factory

Recently, I started learning AngularJS and have been struggling to fetch JSON data from a factory. The error message I keep getting is not very helpful: TypeError: Cannot read property '1' of null This is the module I am working with: var app ...

Collaborating with Ladda button functionality

I have a button with ladda functionality, shown below. <button class="btn btn-primary btn-xs ladda-button" data-style="slide-left" data-size="xs" v-on:click="refreshPage()">Refresh</button> The onClick event is triggered by VueJs. When the b ...

"Troubleshooting why React fails to update an array state

When I click the update name button, the state is not changing properly using setState. I want to update the persons variable and have it reflect in the DOM as well. Any ideas on how to achieve this? App.js import React, { Component } from "react"; impo ...

Guide to accessing a particular object key within an array by leveraging the MUI multiple autocomplete feature coupled with the useState hook

How can I retrieve the id key from a selected object in a given array list and set it to the state? You can find a sandbox example at this link: https://codesandbox.io/s/tags-material-demo-forked-ffuvg4?file=/demo.js ...

Expanding size on hover without affecting the alignment of surrounding elements

Imagine there are 10 divs on the page styled as squares, collectively known as the home page. Among these 10: 3 divs belong to the .event1 class, 5 divs belong to the .event2 class, and 2 divs belong to the .event3 class. <div class="boxes event1"> ...

What is the syntax for accessing an element within an array in a function?

This code snippet retrieves an array of users stored in a Firestore database. Each document in the collection corresponds to a user and has a unique ID. const [user] = useAuthState(auth); const [userData, setUserData] = useState([]); const usersColl ...

Cytoscape arrangements - Managing immovable nodes

I am currently utilizing vue-cytoscape to display a graph and explore through a tree-like data structure. My main objective is to expand the parent nodes while maintaining their positions in the graph. I want to seamlessly incorporate the new child nodes ...

How do you display a nested object in React after merging it?

To display the JSON below as an image, click https://i.stack.imgur.com/tixu4.png let finalSplit = [ { start: "73", end: "76", splits: [ { word: "Now", start: "73", ...

Is there a way to encase each v-if statement in my Vue code with a transition effect?

Writing the code for transitions can be quite laborious. <transition name="fade"> <div v-if="condition"> </div> </transition> Is there a simpler way to automatically wrap each v-if with a transition? ...

Choose a collection of elements and encase them within a <div> tag

I am currently working on creating a greasemonkey script for a webpage that has a rather challenging structure. My goal is to show and hide different entries, but the content is formatted like this: <a name="first"/> <h3>First</h3> Some ...

Troubleshooting Cache Problems in Express.js 4.0 during Development

Recently, I created a fresh express.js application using the express-generator. However, when I attempt to make modifications, none of them seem to reflect when I refresh the browser. I have tried various solutions found online, including: Disabling Chr ...

WebDriverError: The preference value for network.http.phishy-userpass-length in Firefox is not valid: exceeds maximum allowed length

Attempting to initiate a new test case using gecko driver (v0.15) with a specific Firefox profile in Protractor 5.1.1. I created the profile based on this guidance: Set firefox profile protractor Upon starting the execution through the protractor configur ...

Encountering a Next.js prerendering issue when using getStaticPaths

I am currently developing a Next.js application. Here is the structure of my files: cpanearme -components -listitem.js -pages -home -index.js -firm -[id].js Below is the code for a list item that redirects to the dynamic rout ...

[Vue alert]: "Maximum" property or method is not declared in the instance but is being referenced during the rendering process

Here is my custom Vue component: Vue.component("product-list", { props: ["products", "maximum-price"], template: ` <div> <div class="row d-flex mb-3 align-items-center p-3 rounded-3 animate__animate ...

The focus is lost when v-if is triggered during input

Within my code, there is an input field: <input type="text" maxlength="2" :value="valueHours" @input="calculateTimes($event)" @blur="updateValueHours($event)"> Accompanied by a list section: <div ...

What is the best way to refresh a PHP function based on a JavaScript event?

I have a website where a div tag shows all the values from a SQL database using PHP. I want to reload this div tag with a JavaScript event, such as clicking on an HTML button. Is it possible to bring back all the values from the SQL database and display th ...

JS: Issue with iterating over objects

Within my JavaScript code, there exists an object named box_object with the following structure: ({ id:"3", text:"this is a box object", connection_parent:["1", "2"], connection_child:["5", "6"], connectiondata_child:{ 0:{id:"5", ...

IE and Firefox display different responses when encountering an empty XML document

When working with jQuery to read an XML file, I occasionally encounter the situation where the XML is empty. In this case, I anticipate that the error function (no_info) will be triggered because the file is not formatted as expected for the dataType. Int ...