Skip to content

Commit 4d28388

Browse files
authored
docs: 📝 update history.push state docs (#10160)
Co-authored-by: pshu <pishu.spf@antfin.com>
1 parent 7ca6a37 commit 4d28388

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

docs/docs/api/api.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Message } from 'umi';
2+
13
# API
24

35
为方便查找,以下内容通过字母排序。
@@ -147,18 +149,30 @@ import { history } from 'umi';
147149
history.push('/list');
148150

149151
// 带参数跳转到指定路由
150-
history.push('/list?a=b&c=d#anchor');
152+
history.push('/list?a=b&c=d#anchor', state);
151153
history.push({
152-
pathname: '/list',
153-
search: '?a=b&c=d',
154-
hash: 'anchor',
155-
});
154+
pathname: '/list',
155+
search: '?a=b&c=d',
156+
hash: 'anchor',
157+
},
158+
{
159+
some: 'state-data',
160+
}
161+
);
162+
163+
// 跳转当前路径,并刷新 state
164+
history.push({}, state)
156165

157166
// 跳转到上一个路由
158167
history.back();
159168
history.go(-1);
160169
```
161170

171+
<Message emoji="🚨">
172+
注意:history.push 和 history.replace 需要使用 `state` 需将 `state` 作为这两个 API 的第二个参数传递
173+
</Message>
174+
175+
162176
路由监听。
163177

164178
```ts

0 commit comments

Comments
 (0)