Skip to content

Commit

Permalink
fix(core/router): 修复了当 currentRouteIndexInHistory 为 0 时,push & replac…
Browse files Browse the repository at this point in the history
…e 不会清除 history[1] 的 bug

这个 bug 典型的问题是造成查询分项成绩时历史记录出错。例如,每次查询分项成绩的页面会堆积在历史记录中,导致点击后退时,不断后退到之前查询过的分项成绩页面。

fix #22
  • Loading branch information
frederick-wang committed Jan 30, 2021
1 parent c433542 commit a962659
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/router.ts
Expand Up @@ -438,7 +438,7 @@ function changeRouter(
switch (changeMode) {
case 'push': {
if (history.length) {
if (currentRouteIndexInHistory) {
if (currentRouteIndexInHistory !== undefined) {
history.length = currentRouteIndexInHistory + 1
}
if (
Expand All @@ -455,7 +455,7 @@ function changeRouter(
}
case 'replace': {
if (history.length) {
if (currentRouteIndexInHistory) {
if (currentRouteIndexInHistory !== undefined) {
history.length = currentRouteIndexInHistory + 1
}
history[history.length - 1] = routeToBeEnter
Expand Down

0 comments on commit a962659

Please sign in to comment.