Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(table): fix ajax demo #4639

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/table/demo/ajax.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 { usePagination } from 'vue-request';
import { computed, defineComponent } from 'vue';
import axios from 'axios';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vue-request 不是包含了 axios 吗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没,内置用的是 Fetch,用 axios 的话只是方便推导类型 😆。不用 axios 也可以,要改改吗

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我先合并进来吧 总觉得怪怪的

const columns = [
{
title: 'Name',
Expand Down Expand Up @@ -76,7 +77,7 @@ type APIResult = {
};

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({
Expand All @@ -87,8 +88,8 @@ export default defineComponent({
loading,
current,
pageSize,
} = usePagination<APIResult>(queryData, {
formatResult: res => res.results,
} = usePagination(queryData, {
formatResult: res => res.data.results,
pagination: {
currentKey: 'page',
pageSizeKey: 'results',
Expand Down