Paging problem, according to the page number to get the corresponding page data, interface calls

Keywords: Javascript axios Attribute

import axios from '@/libs/api.request'

const MODULE_URL = '/log';

export const actionLogData = (params, cb) => {
    url: `${MODULE_URL}/actionLog`,//Interface location
    method: 'get',


Page Paging Problem.

<Page class="table-page clearfix" :total="" :pageSize="paging.pageSize" :current="paging.pageNo" show-total show-elevator @on-change="pageChange"/>


Tot= "paging. total" denotes how many pieces of data exist in the total.

pageSize="paging.pageSize" indicates how many pieces of data need to be displayed on a page.

Curr= "paging. pageNo" denotes the current page number.

@ on-change="pageChange" means that the pagechange function is triggered when the corresponding page number is clicked.

1. Import interface.

  import { actionLogData } from '@/api/log';


2. Declare global variables in export default {} and set the initial value of page data.
  export default {
    data() {
      return {
getdata : [],//Declare global variables
        // List page number
         paging: {
           pageNum: 1,
           pageSize: 13,
           total: 0,       


3. Make interface calls in methods:{} and write them into the function initList, where params specifies the parameters that need to be input when calling the interface. By calling the actionLogData interface to get the required values, we can first use console.log(res) to determine which attribute values in the acquired data.

When the page number is clicked for data switching, the page of the corresponding page is obtained, and the function pageChange(page) is called to obtain the data in the corresponding page.
   methods: {
      initList() {
        const params = {
          pageSize: this.paging.pageSize,
          pageNo: this.paging.pageNum,

          if (!res.status) {
            console.log('Request encountered an error!');
          const { data } = res;
          this.getdata = data.list; //get data
 =; //Quantity of total data obtained
        }, err => {
          this.$Message.error('Request encountered an error!Please try again later.');

      /*Page number switching*/
      pageChange(page) {
        this.paging.pageNum = page;


4. At the same time, a back-end request is made in mounted() to fetch data.

    mounted() {


Posted by temujinleal on Tue, 08 Oct 2019 04:55:20 -0700