Replies: 1 comment
-
help 🌝 @yimingjfe |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在 Modern.js 2.x 的 loader(page.loader.ts)中可以接受路由参数(例如:user/:id)。
如果分页通过路由参数实现(user/:pageNo/:pageSize),感觉太笨拙了。
我想问,如何在 loader 中优雅的传递分页参数?
官网给的例子是
const { data } = useLoaderData() as LoaderData;
没有展示如何传递参数
我原来的代码是
import { http, ResponseData } from '../http'
import { AxiosPromise } from 'axios'
interface IQuery {
pageNo?: number;
pageSize?: number
}
// 查询列表
export const getList = (data: IQuery): AxiosPromise<ResponseData> => {
return http.request({
method: 'GET',
url: '/v1/project',
data,
})
}
请问是要在 loader 中声明查询接口,还是在其他位置声明(例如:另起一个 api 目录)。
如果在 loader 中有更优雅的方式,请告知并补充到官网文档。谢谢!
Beta Was this translation helpful? Give feedback.
All reactions