在页面开发中需要定时请求表格数据
1.请求数据
const { data, error, loading, run } = useRequest(
(requestData) => ({
url: '/api/exception/getQueryExcMsg',
method: 'POST',
data: requestData,
headers: {
'token': localStorage.getItem('token')
}
}),
{
pollingInterval: POLLINT_TIME,
manual: true,
},
);
2.更新数据
useEffect(() => {
setTableData(data?.queryExcMsgVos);
setTotal(data?.total);
}, [data]);
const getTableData = (currentPage: number, currentPageSize: number, options?: object | null) => {
const requestData = {
limit: currentPageSize,
page: currentPage,
...options,
};
run(requestData);
};
3.表现
getTableData={getTableData}