使用 antd/procomponents/pro-table 中的困惑

2023-03-02 19:19:12 +08:00
 oppddd
1389 次点击
所在节点    React
4 条回复
oppddd
2023-03-02 19:24:26 +08:00
react-query 的请求方式

```tsx
const { data, isLoading, refetch } = useQuery(['org-user-table', orgId, query], {
queryFn: () => {
return queryUserListUsingPOST({
size: query.pageSize || 20,
current: query.current || 1,
byCondition: {
name: query.name,
orgId: Number(orgId) || 0,
state: query.state || '',
},
})
},
})
```

```tsx
<ProTable
// 请注意修改主键 id
rowKey={'roleId'}
columns={columns}
pagination={{ pageSize: 10, showQuickJumper: true }}
request={
// 这里发起请求
() => {
return Promise()
}
}>
</ProTable>
```

这两个怎么配合啊,因为 ant 官方推荐使用 request 请求(会自己管理请求参数,分页等);
Sendya
2023-03-02 23:51:05 +08:00
类似这样


```tsx
<ProTable
rowKey={'roleId'}
columns={columns}
request={async (params, sorter) => {
const { data, total = 0 } = await queryUserListUsingPOST(params);
return {
data,
totla,
success: true,
}
}}
/>

```
oppddd
2023-03-03 09:54:08 +08:00
嗯,我其实想让 table 变成木偶组件;这样我就可以使用 react-query 了
LOWINC
2023-03-09 09:44:52 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/920604

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX