docs(table): fix ajax demo (#4639)

refactor-table
John 2021-09-10 17:11:02 +08:00 committed by GitHub
parent 6e85fd92e3
commit ba743b29b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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',