Vite + React + Antd Mobile 组件库
t('index.title"')
; ``` 国际化文字映射在`src/locales`文件夹下 6. 发送请求 首先在`src/api`中新增请求文件`xxx.ts`,并定义返回值与参数的`ts interface`,利用 `axios-hooks`发送对应的`http`请求 ```js import useAxios from "axios-hooks"; import { Page, Result } from "@/types/http"; export interface MockResult { id: number; } export interface MockPage { id: number; } /** * fetch the data * 详细使用可以查看 useAxios 的文档 */ export const useFetchXXX = () => { // set the url const url = `/xxx/xxx`; // fetch the data const [{ data, loading, error }, refetch] = useAxios < Result < MockResult >> url; // to do something return { data, loading, error, refetch }; }; /** * fetch the data with page * 详细使用可以查看 useAxios 的文档 */ export const useFetchPageXXX = (page: number, size: number) => { // set the url const url = `/xxx/xxx?page=${page}&size=${size}`; // fetch the data const [{ data, loading, error }, refetch] = useAxios < Page < MockResult >> url; // to do something return { data, loading, error, refetch }; }; ``` `useAxios`返回值分别为`数据`、`状态`、`错误`、`操作对象`(`refetch`用于中断请求) 7. 路由与缓存配置可直接参考代码 ## 补充 ```shell pnpm i pnpm run dev ```