Skip to content

Commit

Permalink
fix(router): 修复ios9下不执行render的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Mar 15, 2019
1 parent b520dfb commit 81cc636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion packages/taro-router/src/history/createHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,16 @@ const createHistory = (props: { basename?: string, mode: "hash" | "browser", fir
listenerCount += delta

if (listenerCount === 1) {
window.addEventListener(PopStateEvent, handlePopState)
const isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent)
if (isSafari) {
window.addEventListener('load', function() {
setTimeout(function() {
window.addEventListener(PopStateEvent, handlePopState)
}, 0);
});
} else {
window.addEventListener(PopStateEvent, handlePopState)
}
} else if (listenerCount === 0) {
window.removeEventListener(PopStateEvent, handlePopState)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-router/src/router/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Route extends Component<RouteProps, {}> {
}

computeMatch (currentLocation) {
const pathname = currentLocation.pathname;
const path = currentLocation.path;
const key = currentLocation.state.key;
const isIndex = this.props.isIndex;
if (isIndex && pathname === '/') return true
if (isIndex && path === '/') return true
return key === this.props.key
}

Expand Down

0 comments on commit 81cc636

Please sign in to comment.