Skip to content

Commit

Permalink
fix(router): 调整页面栈推入时机
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Jan 4, 2022
1 parent 72de7c1 commit 005aa54
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/taro-router/src/router/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export default class PageHandler {
load (page: PageInstance, pageConfig: Route = {}, stacksIndex = 0) {
if (!page) return

// NOTE: 页面栈推入太晚可能导致 getCurrentPages 无法获取到当前页面实例
stacks.push(page)
let pageEl = document.getElementById(page.path!)
if (pageEl) {
setDisplay(pageEl)
Expand All @@ -169,7 +171,6 @@ export default class PageHandler {
this.onReady(page, true)
})
}
stacks.push(page)
page.onShow?.()
bindPageScroll(page, pageConfig)
}
Expand Down

0 comments on commit 005aa54

Please sign in to comment.