Skip to content

Commit

Permalink
描述getPath的携带参数
Browse files Browse the repository at this point in the history
  • Loading branch information
carla-cn committed Oct 11, 2023
1 parent d9fdb3d commit e66bf4c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/frontend/engineering/umi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ html {
#### 页面跳转

- 项目中有一个可以获取路径的函数,getPath
- 页面路径跟组件名称有对应关系,思路是 `getPath(所有页面组件 => 所有页面组件.跳转的页面组件名称)` 即可拿到要跳转的路径
- 页面路径跟组件名称有对应关系,思路是 `getPath(所有页面组件 => 所有页面组件.跳转的页面组件名称, {参数1, 参数2, ...})` 即可拿到要跳转的路径
- umi 提供的跳转的 hook,[useNavigate](https://umijs.org/docs/api/api#usenavigate)

```ts
Expand All @@ -157,7 +157,10 @@ import { useNavigate } from "umi";

const navigate = useNavigate();
const handleClick = () => {
navigate(getPath((component) => component.Step1_2));
navigate(
getPath((component) => component.Step1_2),
{ param: "a", query1: "b", query2: "c" }
); // /xxx/step1-2/a?query1=b&query2=c
};
```

Expand Down

0 comments on commit e66bf4c

Please sign in to comment.