From b83fd4d365d89700250f580f48e318a9550c1fff Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Fri, 23 Apr 2021 23:18:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(router):=20=E4=BF=AE=E5=A4=8D=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=B5=8F=E8=A7=88=E5=99=A8=E8=BF=94=E5=9B=9E=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-router/src/router.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/taro-router/src/router.ts b/packages/taro-router/src/router.ts index 368f22217187..3e3adbb63589 100644 --- a/packages/taro-router/src/router.ts +++ b/packages/taro-router/src/router.ts @@ -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 @@ -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)