react-router setRouteLeaveHook 判断后退与链接跳转的回调区分

用的官网的一个方法

const { route } = this.props
const { router } = this.context
router.setRouteLeaveHook(route, this.routerWillLeave.bind(this))

有个场景就是点回退的时候 需要触发 , 点击链接的时候跳转是不需要触发 , 现在react-router 这块是无法区分的,请问有什么办法区分吗?

阅读 4.8k
1 个回答
新手上路,请多包涵

你好 我想下您是怎么获取到this.props下的router的 我引入了widthRouter之后this.props里还是没有route

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进