阮一峰 router 基础教程 http://www.ruanyifeng.com/blog/2016/05/react_router.html
场景 使用触摸板 对浏览器进行前进后退,导致页面的路由Menu没有发生变化
解决办法:通过对路由添加监听事件,手动触发onClick 事件
componentDidMount() {
// 给当前路由加入监听事件
this.props.history.listen(location => {
// 判断当前路由地址 和 发生变化后的 路由地址 是否一致
if(this.props.location.pathname!==location.pathname){
// 不一致的请情况下可以触发函数进行处理
// this.function()
...
}
}
}