docs(table): fix ajax demo (#4639)
parent
6e85fd92e3
commit
ba743b29b6
|
@ -38,6 +38,7 @@ This example shows how to fetch and present data from a remote server, and how t
|
||||||
import type { TableProps } from 'ant-design-vue';
|
import type { TableProps } from 'ant-design-vue';
|
||||||
import { usePagination } from 'vue-request';
|
import { usePagination } from 'vue-request';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import axios from 'axios';
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: 'Name',
|
title: 'Name',
|
||||||
|
@ -76,7 +77,7 @@ type APIResult = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryData = (params: APIParams) => {
|
const queryData = (params: APIParams) => {
|
||||||
return `https://randomuser.me/api?noinfo&${new URLSearchParams(params)}`;
|
return axios.get<APIResult>('https://randomuser.me/api?noinfo', { params });
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
@ -87,8 +88,8 @@ export default defineComponent({
|
||||||
loading,
|
loading,
|
||||||
current,
|
current,
|
||||||
pageSize,
|
pageSize,
|
||||||
} = usePagination<APIResult>(queryData, {
|
} = usePagination(queryData, {
|
||||||
formatResult: res => res.results,
|
formatResult: res => res.data.results,
|
||||||
pagination: {
|
pagination: {
|
||||||
currentKey: 'page',
|
currentKey: 'page',
|
||||||
pageSizeKey: 'results',
|
pageSizeKey: 'results',
|
||||||
|
|
Loading…
Reference in New Issue