Skip to content

Commit

Permalink
fix: relanch logic change for fix #6733
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Aug 13, 2020
1 parent 698843a commit e7db1cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/taro-router/src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const createReLaunch = ({ customRoutes }: RouterConfig, history?: History) => {
// setTimeout hack
// 修复 history.go 之后,后面的代码不执行的问题
setTimeout(() => {
console.log('setTimeout', url, history)
if (history) {
if (/^(https?:)\/\//.test(url)) {
window.location.assign(url)
Expand All @@ -200,7 +201,10 @@ const createReLaunch = ({ customRoutes }: RouterConfig, history?: History) => {
res.errMsg = 'reLaunch:ok'
resolve(res)
}, 50)
if (history) {
const key = window.history.state.key * 1
if (key > 0) {
window.history.go(-key)
} else if (history) {
history.go(-(history.length - 1))
} else {
window.history.go(-(window.history.length - 1))
Expand Down

0 comments on commit e7db1cb

Please sign in to comment.