Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 记录最后一个location,浏览器前进后退按钮用
lastLocation = {...nextState.location}
stateKey = Number(nextState.location.state!.key)
serialize()
history.length = globalHistory.length
const params = {
fromLocation,
toLocation: history.location,
action: history.action
}
Taro._$router = history.location
Taro.eventCenter.trigger('__taroRouterChange', {...params})
transitionManager.notifyListeners({...params})
}
render () {
const currentLocation = Taro._$router
return (
<div style="{{">
{this.state.routeStack.map(({ path, componentLoader, isIndex, key, isRedirect }, k) => {
return (
</div>
const listen = (listener: History.LocationListener) => {
if (listeners.length) return noop
listeners.push(listener)
return () => {
listeners.length = 0
}
}
const notify = (opts) => {
listeners.forEach(v => {
v(opts)
})
}
Taro._$router = initLocation
const history = {
listen,
location: initLocation,
notify
}
export default () => {
return history
}