Skip to content

Commit

Permalink
fix(router): 修复点击浏览器返回按钮异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Apr 25, 2021
1 parent 280de60 commit b83fd4d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/taro-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { history } from './history'
import { stacks } from './stack'
import { init, routerConfig } from './init'
import { bindPageScroll } from './scroll'
import { setRoutesAlias, addLeadingSlash, historyBackDelta } from './utils'
import { setRoutesAlias, addLeadingSlash, historyBackDelta, setHistoryBackDelta } from './utils'

export interface Route extends PageConfig {
path?: string
Expand Down Expand Up @@ -150,11 +150,12 @@ export function createRouter (

if (action === 'POP') {
unloadPage(Current.page)
// 最终必须重置为 1
let delta = historyBackDelta
while (delta-- > 1) {
unloadPage(stacks.slice(-1)[0])
}
// 最终必须重置为 1
setHistoryBackDelta(1)
const prev = stacks.find(s => s.path === location.pathname + stringify(qs()))
if (prev) {
showPage(prev, pageConfig)
Expand Down

0 comments on commit b83fd4d

Please sign in to comment.