Skip to content

Commit

Permalink
fix(router-h5): iOS12里面返回Hash会丢问题 (#1285)
Browse files Browse the repository at this point in the history
* fix(router): iOS12里面返回Hash会丢问题

* fix(router): iOS12里面返回Hash会丢问题优化,增加兼容处理
  • Loading branch information
sunhaikuo authored and luckyadam committed Nov 28, 2018
1 parent 14af9c7 commit 1bceea3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/taro-router/src/lib/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ class History {
}

onHashchange = (e) => {
history.replaceState(historyState, '', '')
const urlList = JSON.parse(localStorage.getItem(HISTORYKEY) || '[]')
const curPageArr = urlList.filter(item => {
return item.state == historyState
})
if(curPageArr && curPageArr.length > 0) {
const fullUrl = curPageArr[0].fullUrl
history.replaceState(historyState, '', '#' + fullUrl)
}else {
history.replaceState(historyState, '', '')
}
}

onPopstate = (e) => {
Expand Down

0 comments on commit 1bceea3

Please sign in to comment.