Skip to content

Commit

Permalink
fix(router): 返回栈遍历优化
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Jul 19, 2021
1 parent 8f4cfef commit 689bbd2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/taro-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ export function createRouter (
}
// 最终必须重置为 1
setHistoryBackDelta(1)
const prevIndex = stacks.findIndex((s, i) => {
return s.path === location.pathname + stringify(qs(i))
})
const prevIndex = stacks.reduceRight((p, s, i) => {
if (p !== 0) return p
else if (s.path === location.pathname + stringify(qs(i))) return i
else return 0
}, 0)
const prev = stacks[prevIndex]
if (prev) {
showPage(prev, pageConfig, prevIndex)
Expand Down

0 comments on commit 689bbd2

Please sign in to comment.